jcs
/subtext
/amendments
/141
tcp: Move TCPResolveName to dnr, put SOCKS code behind an ifdef
jcs made amendment 141 over 2 years ago
--- dnr.c Thu Sep 17 14:11:02 2020
+++ dnr.c Sun Jun 12 22:43:39 2022
@@ -305,4 +305,35 @@ MXInfo(char *hostName, struct returnRec *returnRecPtr,
return ((*dnr)(MXINFO, hostName, returnRecPtr, resultProc, userDataPtr));
}
-#endif
+#endif
+
+OSErr
+TCPResolveName(char **name, unsigned long *ipAddress)
+{
+ OSErr osErr;
+ struct hostInfo aHostInfo;
+ volatile int done = 0;
+
+ osErr = OpenResolver(nil);
+ if (osErr)
+ return osErr;
+
+ osErr = StrToAddr(*name, &aHostInfo, (ResultProcPtr)StrToAddrMarkDone,
+ (char *)&done);
+
+ if (osErr == cacheFault) {
+ /* StrToAddrMarkDone will set done when DNS resolution finishes */
+ while (!done)
+ ;
+ }
+
+ if ((aHostInfo.rtnCode == noErr) || (aHostInfo.rtnCode == cacheFault)) {
+ /* use the first IP address for this host */
+ *ipAddress = aHostInfo.addr[0];
+ osErr = noErr;
+ } else
+ osErr = aHostInfo.rtnCode;
+
+ CloseResolver();
+ return osErr;
+}
--- tcp.c Sun May 15 22:13:11 2022
+++ tcp.c Mon Jun 13 16:00:07 2022
@@ -6,6 +6,9 @@
#define TCP_BUFFER_SIZE 8192
#define OPEN_TIMEOUT 60
+/* define to enable SOCKS5 code */
+#undef SOCKS
+
short gIPPDriverRefNum;
pascal void StrToAddrMarkDone(struct hostInfo *hi, char *data);
@@ -388,38 +391,7 @@ StrToAddrMarkDone(struct hostInfo *hi, char *data)
volatile int *done = (int *)data;
*done = 1;
}
-
-OSErr
-TCPResolveName(char **name, unsigned long *ipAddress)
-{
- OSErr osErr;
- struct hostInfo aHostInfo;
- volatile int done = 0;
- osErr = OpenResolver(nil);
- if (osErr)
- return osErr;
-
- osErr = StrToAddr(*name, &aHostInfo, (ResultProcPtr)StrToAddrMarkDone,
- (char *)&done);
-
- if (osErr == cacheFault) {
- /* StrToAddrMarkDone will set done when DNS resolution finishes */
- while (!done)
- ;
- }
-
- if ((aHostInfo.rtnCode == noErr) || (aHostInfo.rtnCode == cacheFault)) {
- /* use the first IP address for this host */
- *ipAddress = aHostInfo.addr[0];
- osErr = noErr;
- } else
- osErr = aHostInfo.rtnCode;
-
- CloseResolver();
- return osErr;
-}
-
long
ip2long(char *ip)
{
@@ -457,6 +429,7 @@ long2ip(unsigned long num, char *ip)
(void)sprintf(ip, (const char *)"%d.%d.%d.%d", tmp[0], tmp[1], tmp[2], tmp[3]);
}
+#ifdef SOCKS
#define SOCKS_VERSION_SOCKS5 0x5
#define SOCKS_METHOD_AUTH_NONE 0x0
#define SOCKS_REQUEST_CONNECT 0x1
@@ -556,4 +529,5 @@ SOCKS5TCPActiveOpen(TCPiopb *pb, StreamPtr stream, ip_
fail:
_TCPClose(pb, stream, nil, nil, false);
return err;
-}
+}
+#endif /* SOCKS */