updated on Tue Jan 10 08:08:34 UTC 2012
[aur-mirror.git] / dbhub-ip / dbhub-bind.patch
blob70c526c8f285abb692949ed1d80a2284b7816706
1 --- src/main.h.orig 2008-02-02 04:02:47.000000000 +0200
2 +++ src/main.h 2009-05-21 12:34:54.861111456 +0300
3 @@ -535,7 +535,7 @@
5 //DB// lang.c variables for DB Hub 0.4
8 +char bindaddr[256];
10 /* Functions */
11 int new_human_user(int sock);
12 --- src/main.c.orig 2008-02-02 20:47:46.000000000 +0200
13 +++ src/main.c 2009-05-21 12:44:12.277722034 +0300
14 @@ -3868,6 +3868,7 @@
15 { "version", no_argument, 0, 'v'},
16 { "workdir", required_argument, 0, 'w'},
17 { "logfile", required_argument, 0, 'l'},
18 + { "bind", required_argument, 0, 'b'},
19 { "debug", optional_argument, 0, 'd'},
20 #ifdef SWITCH_USER
21 { "uid", required_argument, 0, 'u'},
22 @@ -4028,17 +4029,17 @@
23 snprintf(pmspammer, 50, "noone");
25 total_share = 0;
27 /* Switch to option processing routines to handle arguments */
29 #ifdef SWITCH_USER
30 - while ( (optres=getopt_long(argc, argv, "shvu:g:w:l:d::", long_options, &optindex))!=-1){
31 + while ( (optres=getopt_long(argc, argv, "shvb:u:g:w:l:d::", long_options, &optindex))!=-1){
32 #else
33 - while ( (optres=getopt_long(argc, argv, "shvw:l:d::", long_options, &optindex))!=-1){
34 + while ( (optres=getopt_long(argc, argv, "shvb:w:l:d::", long_options, &optindex))!=-1){
35 #endif
36 switch (optres){
37 case 'h':
38 printf("DB Hub, version %s\n", VERSION);
39 + printf(" -b, --bind ip : Bind to ip.\n");
40 printf(" -d, --debug [level] : Debug mode. Prevents DB Hub from making itself a\n background daemon. Optional level ist verbosity.\n");
41 printf(" -h, --help : Print this help and exit.\n");+ printf(" -v, --version : Print version.\n");
42 printf(" -l, --logfile <logfile> : Set logfile.\n");
43 @@ -4079,6 +4080,9 @@
44 case 's':
45 logusesyslog=1;
46 break;
47 + case 'b':
48 + strncpy(bindaddr, optarg, (sizeof(bindaddr)-1));
49 + break;
50 case 'd':
51 debug=1;
52 if (optarg) verbosity=atoi(optarg);
53 --- src/network.c.orig 2008-02-01 01:41:36.000000000 +0200
54 +++ src/network.c 2009-05-21 12:46:01.171044985 +0300
55 @@ -377,7 +377,10 @@
56 if (set_to_localhost) {
57 inet_pton(AF_INET, "127.0.0.1", &hub_addr.sin_addr);
58 } else {
59 - hub_addr.sin_addr.s_addr = INADDR_ANY;
60 + if(bindaddr)
61 + inet_pton(AF_INET, bindaddr, &hub_addr.sin_addr);
62 + else
63 + hub_addr.sin_addr.s_addr = INADDR_ANY;
65 hub_addr.sin_port = htons(port);
67 @@ -498,7 +501,10 @@
70 hub_addr.sin_family = AF_INET;
71 - hub_addr.sin_addr.s_addr = INADDR_ANY;
72 + if(bindaddr)
73 + inet_pton(AF_INET, bindaddr, &hub_addr.sin_addr);
74 + else
75 + hub_addr.sin_addr.s_addr = INADDR_ANY;
76 hub_addr.sin_port = htons(port);
77 memset(hub_addr.sin_zero, 0, 8);