There are problem in the all versions: in Linux (FreePascal) the synapse lib could not to resolve connection to https url with HTTPs Proxy.
The problem is solved by the following changes in the code (or rather by deleting a line)
In the trunk code (tp comment 3923 line)
procedure TTCPBlockSocket.HTTPTunnelDoConnect(IP, Port: string); //bugfixed by Mike Green (mgreen@emixode.com) var s: string; begin //Port := IntToStr(ResolvePort(Port)); inherited Connect(FHTTPTunnelIP, FHTTPTunnelPort); if FLastError <> 0 then Exit; FHTTPTunnel := False; if IsIP6(IP) then IP := '[' + IP + ']'; SendString('CONNECT ' + IP + ':' + Port + ' HTTP/1.0' + CRLF); if FHTTPTunnelUser <> '' then Sendstring('Proxy-Authorization: Basic ' + EncodeBase64(FHTTPTunnelUser + ':' + FHTTPTunnelPass) + CRLF); SendString(CRLF); repeat s := RecvTerminated(FHTTPTunnelTimeout, #$0a); if FLastError <> 0 then Break; if (Pos('HTTP/', s) = 1) and (Length(s) > 11) then FHTTPTunnel := s[10] = '2'; until (s = '') or (s = #$0d); if (FLasterror = 0) and not FHTTPTunnel then FLastError := WSAECONNREFUSED; FHTTPTunnelRemoteIP := IP; FHTTPTunnelRemotePort := Port; ExceptCheck; end;
So ResolvePort converts it to big endian
Is that line completely useless or has it a purpose? Rather than removing it, one could fix the endianess with
Above the proposed patch in the code I've seen another construction.
Instead of your
ntohs(ResolvePort(Port))
theSwapEndian(ResolvePort(Port))
is used.I've tested
SwapEndian
withxidel
and it seems to be functional. What do you think?ntohs, htons and SwapEndian are all doing the same swapping on little endian systems.
But this is all wrong.
The true problem seems to be
Result := synsock.htons(StrToIntDef(Port, 0));
in ssfpc.inc:861 ResolvePort
That is where ssfpc's ResolvePort pointlessly changes the endianess to big-endian, while the other ResolvePort functions in ssposix.inc, sslinux.inc, sswin32.inc return system/little endian.
That synsock.htons call needs to be removed
And at any call to ResolvePort that works right now on linux, a swap function needs to be added or removed
Last edit: Benito van der Zander 2020-10-27
Fixed (I hope!)