From 0015af3bb60a6f123ef4cc4a459d85c7cf980d60 Mon Sep 17 00:00:00 2001 From: bebopagogo Date: Sat, 8 Jun 2024 17:20:27 -0400 Subject: [PATCH 1/5] some 'norp' code cleanup --- norp/include/protoPktSOCKS.h | 34 ++++++++++++++++++---------------- norp/src/common/norp.cpp | 3 ++- 2 files changed, 20 insertions(+), 17 deletions(-) diff --git a/norp/include/protoPktSOCKS.h b/norp/include/protoPktSOCKS.h index 9624525..2a1f0ae 100755 --- a/norp/include/protoPktSOCKS.h +++ b/norp/include/protoPktSOCKS.h @@ -152,15 +152,15 @@ namespace ProtoPktSOCKS UINT8 GetVersion() const {return ((pkt_length > OFFSET_VERSION) ? - (((UINT8*)buffer_ptr)[OFFSET_VERSION]) : 0);} + GetUINT8(OFFSET_VERSION) : 0);} Command GetCommand() const {return ((pkt_length > OFFSET_COMMAND) ? - (Command)(((UINT8*)buffer_ptr)[OFFSET_COMMAND]) : CMD_INVALID);} + (Command)GetUINT8(OFFSET_COMMAND) : CMD_INVALID);} AddrType GetAddressType() const {return ((pkt_length > OFFSET_ATYPE) ? - (AddrType)(((UINT8*)buffer_ptr)[OFFSET_ATYPE]) : ADDR_INVALID);} + (AddrType)GetUINT8(OFFSET_ATYPE) : ADDR_INVALID);} UINT8 GetAddressLength() const; @@ -175,18 +175,18 @@ namespace ProtoPktSOCKS void SetVersion(UINT8 version) { - ((UINT8*)buffer_ptr)[OFFSET_VERSION] = version; + SetUINT8(OFFSET_VERSION, version); pkt_length = 1; } void SetCommand(Command cmd) { - ((UINT8*)buffer_ptr)[OFFSET_COMMAND] = (UINT8)cmd; + SetUINT8(OFFSET_COMMAND, (UINT8)cmd); pkt_length = 2; } void SetAddressType(AddrType addrType) { ((UINT8*)buffer_ptr)[OFFSET_RESERVED] = 0; - ((UINT8*)buffer_ptr)[OFFSET_ATYPE] = (UINT8)addrType; + SetUINT8(OFFSET_ATYPE, (UINT8)addrType); pkt_length = 4; } bool SetAddress(const ProtoAddress& theAddr); // note this sets port, too @@ -242,18 +242,19 @@ namespace ProtoPktSOCKS bool freeOnDestruct = false) {return ProtoPkt::InitFromBuffer(replyLength, bufferPtr, numBytes, freeOnDestruct);} + AddrType GetAddressType() const UINT8 GetVersion() const {return ((pkt_length > OFFSET_VERSION) ? - (((UINT8*)buffer_ptr)[OFFSET_VERSION]) : 0);} + GetUINT8(OFFSET_VERSION) : 0);} Type GetType() const {return ((pkt_length > OFFSET_TYPE) ? - (Type)(((UINT8*)buffer_ptr)[OFFSET_TYPE]) : TYPE_INVALID);} + (Type)GetUINT8(OFFSET_TYPE) : CMD_INVALID);} AddrType GetAddressType() const {return ((pkt_length > OFFSET_ATYPE) ? - (AddrType)(((UINT8*)buffer_ptr)[OFFSET_ATYPE]) : ADDR_INVALID);} - + (AddrType)GetUINT8(OFFSET_ATYPE) : ADDR_INVALID);} + UINT8 GetAddressLength() const; const char* GetAddressPtr() const @@ -266,12 +267,12 @@ namespace ProtoPktSOCKS // Reply building (call these in order void SetVersion(UINT8 version) { - ((UINT8*)buffer_ptr)[OFFSET_VERSION] = version; + SetUINT8(OFFSET_VERSION, version); pkt_length = 1; } void SetType(Type replyType) { - ((UINT8*)buffer_ptr)[OFFSET_TYPE] = (UINT8)replyType; + SetUINT8(OFFSET_TYPE, (UINT8)replyType); pkt_length = 2; } void SetAddress(AddrType addrType, const char* addrPtr, UINT8 addrLen); @@ -316,12 +317,12 @@ namespace ProtoPktSOCKS UINT8 GetFrag() const {return ((pkt_length > OFFSET_FRAG) ? - (((UINT8*)buffer_ptr)[OFFSET_FRAG]) : 0);} + GetUINT8(OFFSET_FRAG) : 0);} AddrType GetAddressType() const {return ((pkt_length > OFFSET_ATYPE) ? - (AddrType)(((UINT8*)buffer_ptr)[OFFSET_ATYPE]) : ADDR_INVALID);} - + (AddrType)GetUINT8(OFFSET_ATYPE) : ADDR_INVALID);} + UINT8 GetAddressLength() const; const char* GetAddressPtr() const @@ -342,7 +343,8 @@ namespace ProtoPktSOCKS void SetFragment(UINT8 fragId) { ((UINT8*)buffer_ptr)[OFFSET_RESERVED] = 0; - ((UINT8*)buffer_ptr)[OFFSET_FRAG] = fragId; + SetUINT8(OFFSET_RESERVED, 0); + SetUINT8(OFFSET_FRAG], fragId); pkt_length = OFFSET_FRAG + 1; } void SetAddress(AddrType addrType, const char* addrPtr, UINT8 addrLen); diff --git a/norp/src/common/norp.cpp b/norp/src/common/norp.cpp index 2579232..84a429c 100755 --- a/norp/src/common/norp.cpp +++ b/norp/src/common/norp.cpp @@ -12,7 +12,7 @@ // numbers for NORM traffic. // Uncomment this to enable new NORM port handling to improve NAT compatibility -#define NEW_PORT +#define NEW_PORT 1 PortPool::PortPool(UINT16 basePort) : base_port(basePort) @@ -533,6 +533,7 @@ bool NorpSession::PutClientAuthReply() else { // AuthReply was fully sent + TRACE("AuthReply fully sent %d bytes ...\n", remote_index); socks_client_socket.StopOutputNotification(); socks_state = SOCKS_GET_REQUEST; remote_pending = remote_index = 0; From 8da63844ed0de380d53a55d16722dc87f4164df6 Mon Sep 17 00:00:00 2001 From: bebopagogo Date: Sat, 8 Jun 2024 17:22:13 -0400 Subject: [PATCH 2/5] some 'norp' code cleanup --- norp/include/protoPktSOCKS.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/norp/include/protoPktSOCKS.h b/norp/include/protoPktSOCKS.h index 2a1f0ae..53fae78 100755 --- a/norp/include/protoPktSOCKS.h +++ b/norp/include/protoPktSOCKS.h @@ -242,14 +242,13 @@ namespace ProtoPktSOCKS bool freeOnDestruct = false) {return ProtoPkt::InitFromBuffer(replyLength, bufferPtr, numBytes, freeOnDestruct);} - AddrType GetAddressType() const UINT8 GetVersion() const {return ((pkt_length > OFFSET_VERSION) ? GetUINT8(OFFSET_VERSION) : 0);} Type GetType() const {return ((pkt_length > OFFSET_TYPE) ? - (Type)GetUINT8(OFFSET_TYPE) : CMD_INVALID);} + (Type)GetUINT8(OFFSET_TYPE) : TYPE_INVALID);} AddrType GetAddressType() const {return ((pkt_length > OFFSET_ATYPE) ? @@ -344,7 +343,7 @@ namespace ProtoPktSOCKS { ((UINT8*)buffer_ptr)[OFFSET_RESERVED] = 0; SetUINT8(OFFSET_RESERVED, 0); - SetUINT8(OFFSET_FRAG], fragId); + SetUINT8(OFFSET_FRAG, fragId); pkt_length = OFFSET_FRAG + 1; } void SetAddress(AddrType addrType, const char* addrPtr, UINT8 addrLen); From f242b53b72528f121ab11db9441ef6bfa15848fe Mon Sep 17 00:00:00 2001 From: bebopagogo Date: Sat, 8 Jun 2024 17:38:25 -0400 Subject: [PATCH 3/5] fix to MacOS Makefile --- norp/makefiles/Makefile.common | 2 +- norp/makefiles/Makefile.macosx | 4 ++-- norp/src/common/norp.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/norp/makefiles/Makefile.common b/norp/makefiles/Makefile.common index b8112e0..8d6568e 100755 --- a/norp/makefiles/Makefile.common +++ b/norp/makefiles/Makefile.common @@ -44,7 +44,7 @@ norp: $(LIBPROTO) $(LIBNORM) $(NORP_OBJ) $(CC) $(LDFLAGS) -o $@ $(NORP_OBJ) $(LIBS) $(LIBNORM) $(LIBPROTO) clean: - rm -f norp $(COMMON)/*.o; + rm -f norp $(COMMON)/*.o $(COMMON)/protoPktSOCKS.o; $(MAKE) -C $(NORM)/makefiles -f Makefile.$(SYSTEM) clean; $(MAKE) -C $(PROTOLIB)/makefiles -f Makefile.$(SYSTEM) clean; diff --git a/norp/makefiles/Makefile.macosx b/norp/makefiles/Makefile.macosx index 81f1984..65edaf1 100755 --- a/norp/makefiles/Makefile.macosx +++ b/norp/makefiles/Makefile.macosx @@ -8,8 +8,8 @@ WX_CFLAGS = `$(WX_CONFIG_PATH) --cxxflags` WX_LIBS = `$(WX_CONFIG_PATH) --libs` # 2) System-specific flags and libs -SYSTEM_CFLAGS = -arch x86_64 -SYSTEM_LIBS = -arch x86_64 -lresolv +SYSTEM_CFLAGS = +SYSTEM_LIBS = -lresolv -lpcap # 3) System-specific Protolib flags (_must_ correspond to Protolib SYSTEM_HAVES) # Must choose appropriate for the following: diff --git a/norp/src/common/norp.cpp b/norp/src/common/norp.cpp index 2579232..94f9d80 100755 --- a/norp/src/common/norp.cpp +++ b/norp/src/common/norp.cpp @@ -12,7 +12,7 @@ // numbers for NORM traffic. // Uncomment this to enable new NORM port handling to improve NAT compatibility -#define NEW_PORT +#define NEW_PORT 1 PortPool::PortPool(UINT16 basePort) : base_port(basePort) From ebc65bd1403c913f3b52dfec53e53aa7443bb51a Mon Sep 17 00:00:00 2001 From: bebopagogo Date: Sat, 8 Jun 2024 17:39:28 -0400 Subject: [PATCH 4/5] pulled updated submodule code --- protolib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protolib b/protolib index dc92c6b..5dd0cbe 160000 --- a/protolib +++ b/protolib @@ -1 +1 @@ -Subproject commit dc92c6b8ccc75a01ecd2d7850f6bc7d8a7fe671d +Subproject commit 5dd0cbe46456a5b0bd3e09dfa6ba15f532447982 From 669fc4f6719a3f05869f7adec4b3a1c5329d007b Mon Sep 17 00:00:00 2001 From: bebopagogo Date: Sat, 8 Jun 2024 18:13:29 -0400 Subject: [PATCH 5/5] brought in protolib with bug fixes --- protolib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/protolib b/protolib index 5dd0cbe..0ea5b00 160000 --- a/protolib +++ b/protolib @@ -1 +1 @@ -Subproject commit 5dd0cbe46456a5b0bd3e09dfa6ba15f532447982 +Subproject commit 0ea5b0091782133c18599fbd5acd9f879c362664