Skip to content

Commit f66b9a6

Browse files
committed
CHANGE: replaced port/spec/port-id with port/spec/port
related to: Oldes/Rebol-issues#2021
1 parent c54b352 commit f66b9a6

11 files changed

+62
-62
lines changed

src/boot/sysobj.reb

+2-2
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ standard: object [
265265

266266
port-spec-net: make port-spec-file [
267267
host: none
268-
port-id: 80
268+
port: 80
269269
]
270270

271271
port-spec-checksum: make port-spec-head [
@@ -491,7 +491,7 @@ view: object [
491491
; user: ; User data
492492

493493
; host:
494-
; port-id:
494+
; port:
495495
; user:
496496
; pass:
497497
; target:

src/core/p-net.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
** REBOL [R3] Language Interpreter and Run-time Environment
44
**
55
** Copyright 2012 REBOL Technologies
6+
** Copyright 2012-2022 Rebol Open Source Contributors
67
** REBOL is a trademark of REBOL Technologies
78
**
89
** Licensed under the Apache License, Version 2.0 (the "License");
@@ -133,7 +134,7 @@ enum Transport_Types {
133134
case A_OPEN:
134135

135136
arg = Obj_Value(spec, STD_PORT_SPEC_NET_HOST);
136-
val = Obj_Value(spec, STD_PORT_SPEC_NET_PORT_ID);
137+
val = Obj_Value(spec, STD_PORT_SPEC_NET_PORT);
137138

138139
if (OS_DO_DEVICE(sock, RDC_OPEN)) Trap_Port(RE_CANNOT_OPEN, port, -12);
139140
SET_OPEN(sock);

src/mezz/prot-http.reb

+14-14
Original file line numberDiff line numberDiff line change
@@ -278,8 +278,8 @@ do-request: func [
278278
Accept: "*/*"
279279
Accept-charset: "utf-8"
280280
Accept-Encoding: "gzip,deflate"
281-
Host: either not find [80 443] spec/port-id [
282-
ajoin [spec/host #":" spec/port-id]
281+
Host: either not find [80 443] spec/port [
282+
ajoin [spec/host #":" spec/port]
283283
][
284284
form spec/host
285285
]
@@ -508,22 +508,22 @@ do-redirect: func [port [port!] new-uri [url! string! file!] /local spec state h
508508
do-request port
509509
return true
510510
]
511-
new-uri: as url! ajoin [spec/scheme "://" spec/host #":" spec/port-id new-uri]
511+
new-uri: as url! ajoin [spec/scheme "://" spec/host #":" spec/port new-uri]
512512
]
513513
new-uri: decode-url new-uri
514514
spec/headers/host: new-uri/host
515515

516-
unless select new-uri 'port-id [
516+
unless select new-uri 'port [
517517
switch new-uri/scheme [
518-
'https [append new-uri [port-id: 443]]
519-
'http [append new-uri [port-id: 80 ]]
518+
'https [append new-uri [port: 443]]
519+
'http [append new-uri [port: 80 ]]
520520
]
521521
]
522522
new-uri: construct/with new-uri port/scheme/spec
523523
new-uri/method: spec/method
524-
new-uri/ref: as url! ajoin either find [#[none] 80 443] new-uri/port-id [
524+
new-uri/ref: as url! ajoin either find [#[none] 80 443] new-uri/port [
525525
[new-uri/scheme "://" new-uri/host new-uri/path]
526-
][ [new-uri/scheme "://" new-uri/host #":" new-uri/port-id new-uri/path]]
526+
][ [new-uri/scheme "://" new-uri/host #":" new-uri/port new-uri/path]]
527527

528528
unless find [http https] new-uri/scheme [
529529
return throw-http-error port {Redirect to a protocol different from HTTP or HTTPS not supported}
@@ -783,12 +783,12 @@ sys/make-scheme [
783783
chunk: none
784784
chunk-size: none
785785
]
786-
;? port/state/info
786+
spec: port/spec
787787
port/state/connection: conn: make port! compose [
788-
scheme: (to lit-word! either port/spec/scheme = 'http ['tcp]['tls])
789-
host: port/spec/host
790-
port-id: port/spec/port-id
791-
ref: as url! ajoin [scheme "://" host #":" port-id]
788+
scheme: (to lit-word! either spec/scheme = 'http ['tcp]['tls])
789+
host: spec/host
790+
port: spec/port
791+
ref: as url! ajoin [scheme "://" host #":" port]
792792
]
793793

794794
conn/awake: :http-awake
@@ -877,6 +877,6 @@ sys/make-scheme/with [
877877
name: 'https
878878
title: "Secure HyperText Transport Protocol v1.1"
879879
spec: make spec [
880-
port-id: 443
880+
port: 443
881881
]
882882
] 'http

src/mezz/prot-mysql.reb

+12-11
Original file line numberDiff line numberDiff line change
@@ -1394,17 +1394,18 @@ mysql-driver: make object! [
13941394

13951395
open-tcp-port: func [
13961396
port [port!] "mysql port"
1397-
/local conn
1397+
/local conn spec
13981398
][
1399+
spec: port/spec
13991400
conn: make port![
14001401
scheme: 'tcp
1401-
host: port/spec/host
1402-
port-id: port/spec/port-id
1403-
ref: rejoin [tcp:// host ":" port-id port/spec/path]
1404-
user: port/spec/user
1405-
pass: port/spec/pass
1406-
path: port/spec/path
1407-
timeout: port/spec/timeout
1402+
host: spec/host
1403+
port: spec/port
1404+
ref: rejoin [tcp:// host ":" port spec/path]
1405+
user: spec/user
1406+
pass: spec/pass
1407+
path: spec/path
1408+
timeout: spec/timeout
14081409
]
14091410

14101411
conn/extra: make locals-class [
@@ -1486,7 +1487,7 @@ sys/make-scheme [
14861487

14871488
spec: make system/standard/port-spec-net [
14881489
path: %""
1489-
port-id: 3306
1490+
port: 3306
14901491
timeout: 120
14911492
user:
14921493
pass: none
@@ -1510,7 +1511,7 @@ sys/make-scheme [
15101511
spec: event/port/spec
15111512
spec/pass: none
15121513
spec/ref: rejoin [
1513-
mysql:// spec/user #"@" spec/host #":" spec/port-id spec/path
1514+
mysql:// spec/user #"@" spec/host #":" spec/port spec/path
15141515
]
15151516
sys/log/info 'MySQL ["Connected:^[[22m" spec/ref]
15161517
pl/handshaked?: true
@@ -1708,7 +1709,7 @@ send-sql: func [
17081709
]
17091710

17101711
throw-timeout: func[port [port!]] [
1711-
cause-error 'Access 'timeout to url! rejoin [port/spec/scheme "://" port/spec/host #":" port/spec/port-id]
1712+
cause-error 'Access 'timeout to url! rejoin [port/spec/scheme "://" port/spec/host #":" port/spec/port]
17121713
]
17131714

17141715
connect-sql: func [

src/mezz/prot-tls.reb

+6-8
Original file line numberDiff line numberDiff line change
@@ -1811,23 +1811,21 @@ sys/make-scheme [
18111811
]
18121812
]
18131813

1814-
open: func [port [port!] /local conn][
1814+
open: func [port [port!] /local conn spec][
18151815
log-more "OPEN"
18161816
if port/state [return port]
18171817

18181818
if none? port/spec/host [TLS-error "Missing host address"]
18191819

1820+
spec: port/spec
18201821
port/state: make-TLS-ctx
1821-
18221822
port/state/connection: conn: make port! [
18231823
scheme: 'tcp
1824-
host: port/spec/host
1825-
port-id: port/spec/port-id
1826-
ref: rejoin [tcp:// host ":" port-id]
1824+
host: spec/host
1825+
port: spec/port
1826+
ref: rejoin [tcp:// host ":" port]
18271827
]
1828-
1829-
port/data: port/state/port-data
1830-
1828+
port/data: port/state/port-data
18311829
conn/awake: :TLS-awake
18321830
conn/extra: port
18331831
open conn

src/mezz/prot-whois.reb

+7-7
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ append system/options/log [whois: 1]
2424
sys/make-scheme [
2525
name: 'whois
2626
title: "WHOIS Protocol"
27-
spec: make system/standard/port-spec-net [port-id: 43 timeout: 15 ]
27+
spec: make system/standard/port-spec-net [port: 43 timeout: 15 ]
2828
awake: func [event /local port parent] [
2929
sys/log/debug 'WHOIS ["Awake:^[[22m" event/type]
3030
port: event/port
@@ -58,7 +58,7 @@ sys/make-scheme [
5858
actor: [
5959
open: func [
6060
port [port!]
61-
/local conn
61+
/local conn spec
6262
] [
6363
if all [
6464
port/state
@@ -72,8 +72,8 @@ sys/make-scheme [
7272
]
7373
return port
7474
]
75-
76-
if none? port/spec/host [ port/spec/host: "whois.iana.org" ]
75+
spec: port/spec
76+
if none? spec/host [ spec/host: "whois.iana.org" ]
7777

7878
port/state: object [
7979
state: 'inited
@@ -83,9 +83,9 @@ sys/make-scheme [
8383
]
8484
port/state/connection: conn: make port! [
8585
scheme: 'tcp
86-
host: port/spec/host
87-
port-id: port/spec/port-id
88-
ref: rejoin [tcp:// host #":" port-id]
86+
host: spec/host
87+
port: spec/port
88+
ref: rejoin [tcp:// host #":" port]
8989
]
9090
conn/extra: port
9191
conn/awake: :awake

src/mezz/sys-ports.reb

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ make-port*: func [
112112
; optional host [:port]
113113
opt [
114114
copy s1 any host-char
115-
opt [#":" copy s2 digits (compose/into [port-id: (to integer! s2)] tail out)]
115+
opt [#":" copy s2 digits (compose/into [port: (to integer! s2)] tail out)]
116116
(unless empty? s1 [attempt [s1: to tuple! s1] emit host s1])
117117
]
118118
]

src/modules/httpd.reb

+6-6
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,13 @@ sys/make-scheme [
197197
Name: 'httpd
198198

199199
Actor: [
200-
Open: func [port [port!]][
201-
; probe port/spec
202-
sys/log/info 'HTTPD ["Opening server at port:^[[22m" port/spec/port-id]
200+
Open: func [port [port!] /local spec][
201+
spec: port/spec
202+
sys/log/info 'HTTPD ["Opening server at port:^[[22m" spec/port]
203203
port/extra: make object! [
204-
subport: open compose [
204+
subport: open [
205205
scheme: 'tcp
206-
port-id: (port/spec/port-id)
206+
port: spec/port
207207
]
208208
subport/awake: :port/scheme/awake-server
209209
subport/extra: make object! [
@@ -225,7 +225,7 @@ sys/make-scheme [
225225
]
226226

227227
Close: func [port [port!]][
228-
sys/log/info 'HTTPD ["Closing server at port:^[[22m" port/spec/port-id]
228+
sys/log/info 'HTTPD ["Closing server at port:^[[22m" port/spec/port]
229229
close port/extra/subport
230230
]
231231

src/modules/port-scanner.reb

+6-6
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ batch-size: 8000 ; higher batch size means higher CPU use!
2020
timeout: 0:0:0.5 ; setting timeout too low may result in not resolved opened ports!
2121

2222
; actor:
23-
on-awake: func [event /local port id] [
23+
on-awake: func [event /local port number] [
2424
port: event/port
25-
;print [as-green "==TCP-event:" as-red event/type "port:" as-red port/spec/port-id]
25+
;print [as-green "==TCP-event:" as-red event/type "port:" as-red port/spec/port]
2626
switch/default event/type [
2727
lookup [open port]
2828
connect [
29-
id: port/spec/port-id
30-
print ["Open port found:" as-red id]
31-
append found id
29+
number: port/spec/port
30+
print ["Open port found:" as-red number]
31+
append found number
3232
false
3333
]
3434
][true]
@@ -71,7 +71,7 @@ scan-ports: function [
7171
port: make port! compose [
7272
scheme: 'tcp
7373
host: (ip)
74-
port-id: (id)
74+
port: (id)
7575
awake: :on-awake
7676
]
7777
open port

src/modules/spotify.reb

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ spotify: object [
2424
client-id: none
2525
client-secret: none
2626
scope: ""
27-
port-id: 8989
27+
port: 8989
2828
token: none
2929
get: func [what [any-string!] ][request self 'GET what none]
3030
put: func [what [any-string!] /with data][request self 'PUT what data]
@@ -44,14 +44,14 @@ authorize: function [
4444
return none
4545
]
4646
unless string? ctx/client-id [ ctx/client-id: form ctx/client-id ]
47-
unless integer? ctx/port-id [ ctx/port-id: 8989 ]
47+
unless integer? ctx/port [ ctx/port: 8989 ]
4848
unless string? ctx/scope [ ctx/scope: form ctx/scope ]
4949

5050
; url-encode spaces in scopes
5151
parse ctx/scope [any [change some #[bitset! #{0064000080}] #"+" | skip]]
5252

5353
redirect-uri: rejoin [
54-
"http%3A%2F%2Flocalhost:" ctx/port-id "%2Fspotify-callback%2F"
54+
"http%3A%2F%2Flocalhost:" ctx/port "%2Fspotify-callback%2F"
5555
]
5656

5757
unless ctx/client-secret [
@@ -81,7 +81,7 @@ authorize: function [
8181
; Result from the server is returned as a redirect, so let's start simple server
8282
; listening on specified port (limited to accept only local requests, as the redirect is
8383
; going from the browser actually.. it automaticaly close itself once data are received
84-
result: system/modules/httpd/http-server/config/actor ctx/port-id [
84+
result: system/modules/httpd/http-server/config/actor ctx/port [
8585
root: #[false] ; we are not serving any content!
8686
keep-alive: #[false]
8787
] [

src/tests/units/port-test.r3

+2-2
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Rebol [
2222
--assert url/user = "švéd"
2323
--assert url/pass = "břéťa"
2424
--assert url/host = "example.com"
25-
--assert url/port-id = 8080
25+
--assert url/port = 8080
2626
--assert url/path = "/get?q=ščř"
2727
--assert url/tag = "kovtička"
2828
--test-- "decode-url http://host?query"
@@ -33,7 +33,7 @@ Rebol [
3333
;@@ https://github.com/Oldes/Rebol-issues/issues/1275
3434
url: decode-url tcp://:9000
3535
--assert url/scheme = 'tcp
36-
--assert url/port-id = 9000
36+
--assert url/port = 9000
3737

3838
===end-group===
3939

0 commit comments

Comments
 (0)