diff --git a/src/boot/sysobj.reb b/src/boot/sysobj.reb index f681ba77f4..c957b1f261 100644 --- a/src/boot/sysobj.reb +++ b/src/boot/sysobj.reb @@ -265,7 +265,7 @@ standard: object [ port-spec-net: make port-spec-file [ host: none - port-id: 80 + port: 80 ] port-spec-checksum: make port-spec-head [ @@ -491,7 +491,7 @@ view: object [ ; user: ; User data ; host: -; port-id: +; port: ; user: ; pass: ; target: diff --git a/src/core/p-net.c b/src/core/p-net.c index 9659b9aa61..95f14515dd 100644 --- a/src/core/p-net.c +++ b/src/core/p-net.c @@ -3,6 +3,7 @@ ** REBOL [R3] Language Interpreter and Run-time Environment ** ** Copyright 2012 REBOL Technologies +** Copyright 2012-2022 Rebol Open Source Contributors ** REBOL is a trademark of REBOL Technologies ** ** Licensed under the Apache License, Version 2.0 (the "License"); @@ -133,7 +134,7 @@ enum Transport_Types { case A_OPEN: arg = Obj_Value(spec, STD_PORT_SPEC_NET_HOST); - val = Obj_Value(spec, STD_PORT_SPEC_NET_PORT_ID); + val = Obj_Value(spec, STD_PORT_SPEC_NET_PORT); if (OS_DO_DEVICE(sock, RDC_OPEN)) Trap_Port(RE_CANNOT_OPEN, port, -12); SET_OPEN(sock); diff --git a/src/mezz/prot-http.reb b/src/mezz/prot-http.reb index 687df906c4..18e3ee9c3e 100644 --- a/src/mezz/prot-http.reb +++ b/src/mezz/prot-http.reb @@ -278,8 +278,8 @@ do-request: func [ Accept: "*/*" Accept-charset: "utf-8" Accept-Encoding: "gzip,deflate" - Host: either not find [80 443] spec/port-id [ - ajoin [spec/host #":" spec/port-id] + Host: either not find [80 443] spec/port [ + ajoin [spec/host #":" spec/port] ][ form spec/host ] @@ -508,22 +508,22 @@ do-redirect: func [port [port!] new-uri [url! string! file!] /local spec state h do-request port return true ] - new-uri: as url! ajoin [spec/scheme "://" spec/host #":" spec/port-id new-uri] + new-uri: as url! ajoin [spec/scheme "://" spec/host #":" spec/port new-uri] ] new-uri: decode-url new-uri spec/headers/host: new-uri/host - unless select new-uri 'port-id [ + unless select new-uri 'port [ switch new-uri/scheme [ - 'https [append new-uri [port-id: 443]] - 'http [append new-uri [port-id: 80 ]] + 'https [append new-uri [port: 443]] + 'http [append new-uri [port: 80 ]] ] ] new-uri: construct/with new-uri port/scheme/spec new-uri/method: spec/method - new-uri/ref: as url! ajoin either find [#[none] 80 443] new-uri/port-id [ + new-uri/ref: as url! ajoin either find [#[none] 80 443] new-uri/port [ [new-uri/scheme "://" new-uri/host new-uri/path] - ][ [new-uri/scheme "://" new-uri/host #":" new-uri/port-id new-uri/path]] + ][ [new-uri/scheme "://" new-uri/host #":" new-uri/port new-uri/path]] unless find [http https] new-uri/scheme [ return throw-http-error port {Redirect to a protocol different from HTTP or HTTPS not supported} @@ -783,12 +783,12 @@ sys/make-scheme [ chunk: none chunk-size: none ] - ;? port/state/info + spec: port/spec port/state/connection: conn: make port! compose [ - scheme: (to lit-word! either port/spec/scheme = 'http ['tcp]['tls]) - host: port/spec/host - port-id: port/spec/port-id - ref: as url! ajoin [scheme "://" host #":" port-id] + scheme: (to lit-word! either spec/scheme = 'http ['tcp]['tls]) + host: spec/host + port: spec/port + ref: as url! ajoin [scheme "://" host #":" port] ] conn/awake: :http-awake @@ -877,6 +877,6 @@ sys/make-scheme/with [ name: 'https title: "Secure HyperText Transport Protocol v1.1" spec: make spec [ - port-id: 443 + port: 443 ] ] 'http diff --git a/src/mezz/prot-mysql.reb b/src/mezz/prot-mysql.reb index c993fd457f..6d6ec00da4 100644 --- a/src/mezz/prot-mysql.reb +++ b/src/mezz/prot-mysql.reb @@ -1394,17 +1394,18 @@ mysql-driver: make object! [ open-tcp-port: func [ port [port!] "mysql port" - /local conn + /local conn spec ][ + spec: port/spec conn: make port![ scheme: 'tcp - host: port/spec/host - port-id: port/spec/port-id - ref: rejoin [tcp:// host ":" port-id port/spec/path] - user: port/spec/user - pass: port/spec/pass - path: port/spec/path - timeout: port/spec/timeout + host: spec/host + port: spec/port + ref: rejoin [tcp:// host ":" port spec/path] + user: spec/user + pass: spec/pass + path: spec/path + timeout: spec/timeout ] conn/extra: make locals-class [ @@ -1486,7 +1487,7 @@ sys/make-scheme [ spec: make system/standard/port-spec-net [ path: %"" - port-id: 3306 + port: 3306 timeout: 120 user: pass: none @@ -1510,7 +1511,7 @@ sys/make-scheme [ spec: event/port/spec spec/pass: none spec/ref: rejoin [ - mysql:// spec/user #"@" spec/host #":" spec/port-id spec/path + mysql:// spec/user #"@" spec/host #":" spec/port spec/path ] sys/log/info 'MySQL ["Connected:^[[22m" spec/ref] pl/handshaked?: true @@ -1708,7 +1709,7 @@ send-sql: func [ ] throw-timeout: func[port [port!]] [ - cause-error 'Access 'timeout to url! rejoin [port/spec/scheme "://" port/spec/host #":" port/spec/port-id] + cause-error 'Access 'timeout to url! rejoin [port/spec/scheme "://" port/spec/host #":" port/spec/port] ] connect-sql: func [ diff --git a/src/mezz/prot-tls.reb b/src/mezz/prot-tls.reb index 0f1c8c141a..73fb7004c4 100644 --- a/src/mezz/prot-tls.reb +++ b/src/mezz/prot-tls.reb @@ -1811,23 +1811,21 @@ sys/make-scheme [ ] ] - open: func [port [port!] /local conn][ + open: func [port [port!] /local conn spec][ log-more "OPEN" if port/state [return port] if none? port/spec/host [TLS-error "Missing host address"] + spec: port/spec port/state: make-TLS-ctx - port/state/connection: conn: make port! [ scheme: 'tcp - host: port/spec/host - port-id: port/spec/port-id - ref: rejoin [tcp:// host ":" port-id] + host: spec/host + port: spec/port + ref: rejoin [tcp:// host ":" port] ] - - port/data: port/state/port-data - + port/data: port/state/port-data conn/awake: :TLS-awake conn/extra: port open conn diff --git a/src/mezz/prot-whois.reb b/src/mezz/prot-whois.reb index badb765cf9..00bed95e06 100644 --- a/src/mezz/prot-whois.reb +++ b/src/mezz/prot-whois.reb @@ -24,7 +24,7 @@ append system/options/log [whois: 1] sys/make-scheme [ name: 'whois title: "WHOIS Protocol" - spec: make system/standard/port-spec-net [port-id: 43 timeout: 15 ] + spec: make system/standard/port-spec-net [port: 43 timeout: 15 ] awake: func [event /local port parent] [ sys/log/debug 'WHOIS ["Awake:^[[22m" event/type] port: event/port @@ -58,7 +58,7 @@ sys/make-scheme [ actor: [ open: func [ port [port!] - /local conn + /local conn spec ] [ if all [ port/state @@ -72,8 +72,8 @@ sys/make-scheme [ ] return port ] - - if none? port/spec/host [ port/spec/host: "whois.iana.org" ] + spec: port/spec + if none? spec/host [ spec/host: "whois.iana.org" ] port/state: object [ state: 'inited @@ -83,9 +83,9 @@ sys/make-scheme [ ] port/state/connection: conn: make port! [ scheme: 'tcp - host: port/spec/host - port-id: port/spec/port-id - ref: rejoin [tcp:// host #":" port-id] + host: spec/host + port: spec/port + ref: rejoin [tcp:// host #":" port] ] conn/extra: port conn/awake: :awake diff --git a/src/mezz/sys-ports.reb b/src/mezz/sys-ports.reb index 5715f2dd4b..b85427c837 100644 --- a/src/mezz/sys-ports.reb +++ b/src/mezz/sys-ports.reb @@ -112,7 +112,7 @@ make-port*: func [ ; optional host [:port] opt [ copy s1 any host-char - opt [#":" copy s2 digits (compose/into [port-id: (to integer! s2)] tail out)] + opt [#":" copy s2 digits (compose/into [port: (to integer! s2)] tail out)] (unless empty? s1 [attempt [s1: to tuple! s1] emit host s1]) ] ] diff --git a/src/modules/httpd.reb b/src/modules/httpd.reb index 3791953fa3..dc945bb4a4 100644 --- a/src/modules/httpd.reb +++ b/src/modules/httpd.reb @@ -197,13 +197,13 @@ sys/make-scheme [ Name: 'httpd Actor: [ - Open: func [port [port!]][ - ; probe port/spec - sys/log/info 'HTTPD ["Opening server at port:^[[22m" port/spec/port-id] + Open: func [port [port!] /local spec][ + spec: port/spec + sys/log/info 'HTTPD ["Opening server at port:^[[22m" spec/port] port/extra: make object! [ - subport: open compose [ + subport: open [ scheme: 'tcp - port-id: (port/spec/port-id) + port: spec/port ] subport/awake: :port/scheme/awake-server subport/extra: make object! [ @@ -225,7 +225,7 @@ sys/make-scheme [ ] Close: func [port [port!]][ - sys/log/info 'HTTPD ["Closing server at port:^[[22m" port/spec/port-id] + sys/log/info 'HTTPD ["Closing server at port:^[[22m" port/spec/port] close port/extra/subport ] diff --git a/src/modules/port-scanner.reb b/src/modules/port-scanner.reb index 6bff8c4c8b..2015bfe667 100644 --- a/src/modules/port-scanner.reb +++ b/src/modules/port-scanner.reb @@ -20,15 +20,15 @@ batch-size: 8000 ; higher batch size means higher CPU use! timeout: 0:0:0.5 ; setting timeout too low may result in not resolved opened ports! ; actor: -on-awake: func [event /local port id] [ +on-awake: func [event /local port number] [ port: event/port - ;print [as-green "==TCP-event:" as-red event/type "port:" as-red port/spec/port-id] + ;print [as-green "==TCP-event:" as-red event/type "port:" as-red port/spec/port] switch/default event/type [ lookup [open port] connect [ - id: port/spec/port-id - print ["Open port found:" as-red id] - append found id + number: port/spec/port + print ["Open port found:" as-red number] + append found number false ] ][true] @@ -71,7 +71,7 @@ scan-ports: function [ port: make port! compose [ scheme: 'tcp host: (ip) - port-id: (id) + port: (id) awake: :on-awake ] open port diff --git a/src/modules/spotify.reb b/src/modules/spotify.reb index 084a439143..5d87027a6a 100644 --- a/src/modules/spotify.reb +++ b/src/modules/spotify.reb @@ -24,7 +24,7 @@ spotify: object [ client-id: none client-secret: none scope: "" - port-id: 8989 + port: 8989 token: none get: func [what [any-string!] ][request self 'GET what none] put: func [what [any-string!] /with data][request self 'PUT what data] @@ -44,14 +44,14 @@ authorize: function [ return none ] unless string? ctx/client-id [ ctx/client-id: form ctx/client-id ] - unless integer? ctx/port-id [ ctx/port-id: 8989 ] + unless integer? ctx/port [ ctx/port: 8989 ] unless string? ctx/scope [ ctx/scope: form ctx/scope ] ; url-encode spaces in scopes parse ctx/scope [any [change some #[bitset! #{0064000080}] #"+" | skip]] redirect-uri: rejoin [ - "http%3A%2F%2Flocalhost:" ctx/port-id "%2Fspotify-callback%2F" + "http%3A%2F%2Flocalhost:" ctx/port "%2Fspotify-callback%2F" ] unless ctx/client-secret [ @@ -81,7 +81,7 @@ authorize: function [ ; Result from the server is returned as a redirect, so let's start simple server ; listening on specified port (limited to accept only local requests, as the redirect is ; going from the browser actually.. it automaticaly close itself once data are received - result: system/modules/httpd/http-server/config/actor ctx/port-id [ + result: system/modules/httpd/http-server/config/actor ctx/port [ root: #[false] ; we are not serving any content! keep-alive: #[false] ] [ diff --git a/src/tests/units/port-test.r3 b/src/tests/units/port-test.r3 index 94dd6007f0..a96d5a2ef6 100644 --- a/src/tests/units/port-test.r3 +++ b/src/tests/units/port-test.r3 @@ -22,7 +22,7 @@ Rebol [ --assert url/user = "švéd" --assert url/pass = "břéťa" --assert url/host = "example.com" - --assert url/port-id = 8080 + --assert url/port = 8080 --assert url/path = "/get?q=ščř" --assert url/tag = "kovtička" --test-- "decode-url http://host?query" @@ -33,7 +33,7 @@ Rebol [ ;@@ https://github.com/Oldes/Rebol-issues/issues/1275 url: decode-url tcp://:9000 --assert url/scheme = 'tcp - --assert url/port-id = 9000 + --assert url/port = 9000 ===end-group===