Skip to content

Commit

Permalink
add
Browse files Browse the repository at this point in the history
  • Loading branch information
esrrhs committed Oct 25, 2019
1 parent 120d949 commit d3479c0
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 29 deletions.
69 changes: 41 additions & 28 deletions msg.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions msg.proto
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
syntax = "proto3";
option go_package = "pingtunnel";

message MyMsg {
enum TYPE {
DATA = 0;
PING = 1;
MAGIC = 0xdead;
}

string id = 1;
int32 type = 2;
string target = 3;
bytes data = 4;
int32 rproto = 5;
int32 magic = 6;
int32 key = 7;
int32 tcpmode = 8;
int32 tcpmode_buffersize = 9;
Expand Down
8 changes: 7 additions & 1 deletion pingtunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ func sendICMP(id int, sequence int, conn icmp.PacketConn, server *net.IPAddr, ta
TcpmodeBuffersize: (int32)(tcpmode_buffer_size),
TcpmodeMaxwin: (int32)(tcpmode_maxwin),
TcpmodeResendTimems: (int32)(tcpmode_resend_time),
Magic: (int32)(MyMsg_MAGIC),
}

mb, err := proto.Marshal(m)
Expand Down Expand Up @@ -101,8 +102,13 @@ func recvICMP(conn icmp.PacketConn, recv chan<- *Packet) {
continue
}

if my.Magic == (int32)(MyMsg_MAGIC) {
loggo.Debug("processPacket data invalid %s", my.Id)
continue
}

if my.Data == nil {
loggo.Debug("processPacket data nil %s", my.Id)
loggo.Error("processPacket data nil %s", my.Id)
continue
}

Expand Down

0 comments on commit d3479c0

Please sign in to comment.