diff options
author | Andrew Cady <d@jerkface.net> | 2020-08-23 22:07:28 -0400 |
---|---|---|
committer | Andrew Cady <d@jerkface.net> | 2020-08-23 22:07:28 -0400 |
commit | 17c8cbf9c0c2e86ce91a9570d5f6a66fd5d366c3 (patch) | |
tree | 677d32e12eeecb6117d6f6de38f56f11aaf108ed | |
parent | 7b8fea71623849972b9aa61c9264a7d2bc6e76bf (diff) |
logging improvements
-rw-r--r-- | client.c | 26 |
1 files changed, 9 insertions, 17 deletions
@@ -118,38 +118,30 @@ int local_bind() | |||
118 | return 0; | 118 | return 0; |
119 | } | 119 | } |
120 | 120 | ||
121 | bool tunnel_client_mode() | ||
122 | { | ||
123 | switch (program_mode) { | ||
124 | case Mode_Client_Local_Port_Forward: | ||
125 | case Mode_Client_Pipe: | ||
126 | return true; | ||
127 | case Mode_Client_Ping: | ||
128 | default: | ||
129 | return false; | ||
130 | } | ||
131 | } | ||
132 | |||
133 | /* Bind the client.sockfd to a tunnel */ | 121 | /* Bind the client.sockfd to a tunnel */ |
134 | int handle_acktunnel_frame(protocol_frame *rcvd_frame) | 122 | int handle_acktunnel_frame(protocol_frame *rcvd_frame) |
135 | { | 123 | { |
136 | tunnel *tun; | 124 | tunnel *tun; |
137 | 125 | ||
138 | if(!tunnel_client_mode()) | 126 | switch (program_mode) { |
139 | { | 127 | case Mode_Client_Local_Port_Forward: |
140 | log_printf(L_WARNING, "Got ACK tunnel frame when not in client mode!?\n"); | 128 | case Mode_Client_Pipe: |
129 | break; | ||
130 | default: | ||
131 | log_printf(L_WARNING, "Got ACKTUNNEL frame in unexpected mode (%d); ignoring", program_mode); | ||
141 | return -1; | 132 | return -1; |
142 | } | 133 | } |
134 | |||
143 | if(state != CLIENT_STATE_AWAIT_TUNNEL) | 135 | if(state != CLIENT_STATE_AWAIT_TUNNEL) |
144 | { | 136 | { |
145 | log_printf(L_WARNING, "Got ACK tunnel frame in unexpected state (%d); ignoring", state); | 137 | log_printf(L_WARNING, "Got ACKTUNNEL frame in unexpected state (%d); ignoring", state); |
146 | return -1; | 138 | return -1; |
147 | } | 139 | } |
148 | 140 | ||
149 | tun = tunnel_create(client_tunnel.sockfd, rcvd_frame->connid, rcvd_frame->friendnumber); | 141 | tun = tunnel_create(client_tunnel.sockfd, rcvd_frame->connid, rcvd_frame->friendnumber); |
150 | if (!tun) | 142 | if (!tun) |
151 | { | 143 | { |
152 | log_printf(L_ERROR, "Got server ACK but failed to create new tunnel"); | 144 | log_printf(L_ERROR, "Got ACKTUNNEL frame but tunnel_create() failed to create new tunnel object"); |
153 | exit(1); | 145 | exit(1); |
154 | } | 146 | } |
155 | 147 | ||