4040#include "rawsend.h"
4141#include "signals.h"
4242
43+ #ifndef PROGNAME
44+ #define PROGNAME "fakehttp"
45+ #endif /* PROGNAME */
46+
4347#ifndef VERSION
4448#define VERSION "dev"
4549#endif /* VERSION */
4650
4751static void print_usage (const char * name )
4852{
49- fprintf (stderr ,
50- "Usage: %s [options]\n"
51- "\n"
52- "Options:\n"
53- " -4 enable IPv4\n"
54- " -6 enable IPv6\n"
55- " -b use custom tcp payload from binary file\n"
56- " -d run as a daemon\n"
57- " -f skip firewall rules\n"
58- " -g disable hop count estimation\n"
59- " -h <hostname> hostname for obfuscation (required)\n"
60- " -i <interface> network interface name (required)\n"
61- " -k kill the running process\n"
62- " -m <mark> fwmark for bypassing the queue\n"
63- " -n <number> netfilter queue number\n"
64- " -r <repeat> duplicate generated packets for <repeat> "
65- "times\n"
66- " -s enable silent mode\n"
67- " -t <ttl> TTL for generated packets\n"
68- " -w <file> write log to <file> instead of stderr\n"
69- " -x <mask> set the mask for fwmark\n"
70- " -z use iptables commands instead of nft\n"
71- "\n"
72- "FakeHTTP version " VERSION "\n" ,
73- name );
53+ static const char * usage_fmt =
54+ "Usage: %s [options]\n"
55+ "\n"
56+ "Basic Options:\n"
57+ " -h <hostname> hostname for obfuscation\n"
58+ " -i <interface> work on specified network interface\n"
59+ "\n"
60+ "General Options:\n"
61+ " -4 process IPv4 connections\n"
62+ " -6 process IPv6 connections\n"
63+ " -d run as a daemon\n"
64+ " -k kill the running process\n"
65+ " -s enable silent mode\n"
66+ " -w <file> write log to <file> instead of stderr\n"
67+ "\n"
68+ "Advanced Options:\n"
69+ " -b <file> use TCP payload from binary file (ignores -h)\n"
70+ " -f skip firewall rules\n"
71+ " -g disable hop count estimation\n"
72+ " -m <mark> fwmark for bypassing the queue\n"
73+ " -n <number> netfilter queue number\n"
74+ " -r <repeat> duplicate generated packets for <repeat> times\n"
75+ " -t <ttl> TTL for generated packets\n"
76+ " -x <mask> set the mask for fwmark\n"
77+ " -z use iptables commands instead of nft\n"
78+ "\n"
79+ "FakeHTTP version " VERSION "\n" ;
80+
81+ fprintf (stderr , usage_fmt , name );
7482}
7583
7684
@@ -81,6 +89,10 @@ int main(int argc, char *argv[])
8189 char * ipproto_info ;
8290
8391 if (!argc || !argv [0 ]) {
92+ print_usage (PROGNAME );
93+ return EXIT_FAILURE ;
94+ } else if (argc == 1 ) {
95+ print_usage (argv [0 ]);
8496 return EXIT_FAILURE ;
8597 }
8698
0 commit comments