Skip to content

Commit 01267ea

Browse files
authored
Update GetRemoteAddr documentation to clarify that it may return nil. (#1149)
1 parent bc6c183 commit 01267ea

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

tool/net/help.txt

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1160,12 +1160,17 @@ FUNCTIONS
11601160
>: shared_key1 == shared_key2
11611161
true
11621162

1163-
GetRemoteAddr() → ip:uint32,port:uint16
1163+
GetRemoteAddr()
1164+
├─→ ip:uint32,port:uint16
1165+
└─→ nil
11641166
Returns client ip4 address and port, e.g. 0x01020304,31337 would
11651167
represent 1.2.3.4:31337. This is the same as GetClientAddr except
1166-
it will use the ip:port from the X-Forwarded-For header, only if
1167-
IsPrivateIp or IsLoopbackIp return true. When multiple addresses
1168-
are present in the header, the last/right-most address is used.
1168+
it will use the ip:port from the X-Forwarded-For header when the
1169+
IP returned by GetClientAddr is a trusted IP (returns true when
1170+
checked against IsTrustedIp). When multiple addresses are present
1171+
in the header, the last/right-most address is used.
1172+
Returns `nil` if the address doesn't parse as IPv4 value (e.g.
1173+
because it is misformatted or an IPv6 address).
11691174

11701175
GetResponseBody()
11711176
├─→ body:str

0 commit comments

Comments
 (0)