From: Matt Corallo Date: Tue, 15 Mar 2022 03:48:47 +0000 (+0000) Subject: Use command-line magic value X-Git-Url: http://git.bitcoin.ninja/?a=commitdiff_plain;h=e18c3c0b38c5be562f6a1e0f268fd743a058d330;p=tunudptotcp Use command-line magic value --- diff --git a/main.cpp b/main.cpp index 2afcf4c..09802ce 100644 --- a/main.cpp +++ b/main.cpp @@ -260,7 +260,7 @@ static int fdr; static int fd[TUN_IF_COUNT]; static struct sockaddr_in dest; static in_addr_t src, tun_src, tun_dest, ipip_src, ipip_dest; -static const uint64_t tcp_init_magic = 0x1badcafedeadbeefULL; +static uint64_t tcp_init_magic; #define PENDING_MESSAGES_BUFF_SIZE (0x3000) #define PACKET_READ_SIZE 1500 @@ -539,13 +539,14 @@ int main(int argc, char* argv[]) { assert(argc > 4 && "Need ipip remote host"); assert(argc > 5 && "Need ipip local host"); assert(argc > 6 && "Need server port"); - assert(argc > 7 && "Need mode (client or server)"); - assert(argc > 8 && "Need src host"); - if (std::string(argv[7]) == std::string("client")) - assert(argc > 9 && "Need dest host"); + assert(argc > 7 && "Need shared secret"); + assert(argc > 8 && "Need mode (client or server)"); + assert(argc > 9 && "Need src host"); + if (std::string(argv[8]) == std::string("client")) + assert(argc > 10 && "Need dest host"); - assert(std::string(argv[7]) == std::string("client") || std::string(argv[7]) == std::string("server")); - are_server = (std::string(argv[7]) == std::string("server")); + assert(std::string(argv[8]) == std::string("client") || std::string(argv[8]) == std::string("server")); + are_server = (std::string(argv[8]) == std::string("server")); // // Parse args into variables @@ -570,12 +571,14 @@ int main(int argc, char* argv[]) { remote_port = atoi(argv[6]); } - src = inet_addr(argv[8]); + tcp_init_magic = atoll(argv[7]); + + src = inet_addr(argv[9]); memset(&dest, 0, sizeof(dest)); if (!are_server) { dest.sin_family = AF_INET; - dest.sin_addr.s_addr = inet_addr(argv[9]); + dest.sin_addr.s_addr = inet_addr(argv[10]); } //