Changeset 535
- Timestamp:
- 12/27/09 20:37:46 (2 years ago)
- Location:
- trunk
- Files:
-
- 8 edited
-
ChangeLog (modified) (1 diff)
-
configure (modified) (10 diffs)
-
src/ocat.c (modified) (6 diffs)
-
src/ocat.h (modified) (3 diffs)
-
src/ocatctrl.c (modified) (3 diffs)
-
src/ocatlibe.c (modified) (1 diff)
-
src/ocatroute.c (modified) (4 diffs)
-
src/ocatsetup.c (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/ChangeLog
r534 r535 2 2 - GarliCat branch merged back into trunk 3 3 - added onioncat-privatehosts.pl to trunk (written by zzz) 4 - option -t did not work correctly 5 - (optional) pid file is removed at exit 6 - SIGUSR1 is handled in preparation for statistics output 7 - controller sessions limited to MAX_DEF_CTRL_SESS (= 5 by default) 4 8 5 9 * version 0.2.1 -
trunk/configure
r534 r535 1 1 #! /bin/sh 2 2 # Guess values for system-dependent variables and create Makefiles. 3 # Generated by GNU Autoconf 2.62 for onioncat 0.2.2.r53 4.3 # Generated by GNU Autoconf 2.62 for onioncat 0.2.2.r535. 4 4 # 5 5 # Report bugs to <rahra@cypherpunk.at>. … … 597 597 PACKAGE_NAME='onioncat' 598 598 PACKAGE_TARNAME='onioncat' 599 PACKAGE_VERSION='0.2.2.r53 4'600 PACKAGE_STRING='onioncat 0.2.2.r53 4'599 PACKAGE_VERSION='0.2.2.r535' 600 PACKAGE_STRING='onioncat 0.2.2.r535' 601 601 PACKAGE_BUGREPORT='rahra@cypherpunk.at' 602 602 … … 1261 1261 # This message is too long to be a string in the A/UX 3.1 sh. 1262 1262 cat <<_ACEOF 1263 \`configure' configures onioncat 0.2.2.r53 4to adapt to many kinds of systems.1263 \`configure' configures onioncat 0.2.2.r535 to adapt to many kinds of systems. 1264 1264 1265 1265 Usage: $0 [OPTION]... [VAR=VALUE]... … … 1331 1331 if test -n "$ac_init_help"; then 1332 1332 case $ac_init_help in 1333 short | recursive ) echo "Configuration of onioncat 0.2.2.r53 4:";;1333 short | recursive ) echo "Configuration of onioncat 0.2.2.r535:";; 1334 1334 esac 1335 1335 cat <<\_ACEOF … … 1423 1423 if $ac_init_version; then 1424 1424 cat <<\_ACEOF 1425 onioncat configure 0.2.2.r53 41425 onioncat configure 0.2.2.r535 1426 1426 generated by GNU Autoconf 2.62 1427 1427 … … 1437 1437 running configure, to aid debugging if configure makes a mistake. 1438 1438 1439 It was created by onioncat $as_me 0.2.2.r53 4, which was1439 It was created by onioncat $as_me 0.2.2.r535, which was 1440 1440 generated by GNU Autoconf 2.62. Invocation command line was 1441 1441 … … 2086 2086 # Define the identity of the package. 2087 2087 PACKAGE='onioncat' 2088 VERSION='0.2.2.r53 4'2088 VERSION='0.2.2.r535' 2089 2089 2090 2090 … … 2237 2237 2238 2238 cat >>confdefs.h <<\_ACEOF 2239 #define SVN_REVISION "53 4"2239 #define SVN_REVISION "535" 2240 2240 _ACEOF 2241 2241 … … 5221 5221 # values after options handling. 5222 5222 ac_log=" 5223 This file was extended by onioncat $as_me 0.2.2.r53 4, which was5223 This file was extended by onioncat $as_me 0.2.2.r535, which was 5224 5224 generated by GNU Autoconf 2.62. Invocation command line was 5225 5225 … … 5274 5274 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 5275 5275 ac_cs_version="\\ 5276 onioncat config.status 0.2.2.r53 45276 onioncat config.status 0.2.2.r535 5277 5277 configured by $0, generated by GNU Autoconf 2.62, 5278 5278 with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" -
trunk/src/ocat.c
r534 r535 94 94 { 95 95 FILE *f; 96 char c; 96 97 97 98 if (!(f = fopen(CNF(pid_file), "w"))) … … 105 106 log_debug("pid_file %s created, pid = %d", CNF(pid_file), getpid()); 106 107 107 if (chown(CNF(pid_file), uid, 0) == -1) 108 log_msg(LOG_ERR, "could not change owner of pid_file \"%s\" to %d: %s", CNF(pid_file), uid, strerror(errno)); 109 110 return 0; 108 if (pipe(CNF(pid_fd)) == -1) 109 { 110 log_msg(LOG_WARNING, "could not open pid pipe: \"%s\"", strerror(errno)); 111 return -1; 112 } 113 114 switch (fork()) 115 { 116 case -1: 117 oe_close(CNF(pid_fd[0])); 118 oe_close(CNF(pid_fd[1])); 119 return -1; 120 121 // child 122 case 0: 123 oe_close(CNF(pid_fd[1])); 124 if (read(CNF(pid_fd[0]), &c, 1) == -1) 125 log_msg(LOG_ERR, "error reading from pid_fd %d: \"%s\"", 126 CNF(pid_fd[0]), strerror(errno)), exit(1); 127 128 if (unlink(CNF(pid_file)) == -1) 129 log_msg(LOG_WARNING, "error deleting pid ]ile \"%s\": \"%s\"", 130 CNF(pid_file), strerror(errno)), exit(1); 131 exit(0); 132 133 // parent 134 default: 135 oe_close(CNF(pid_fd[0])); 136 137 } 138 139 return CNF(pid_fd[1]); 111 140 } 112 141 … … 164 193 CNF(sig_term) = 1; 165 194 break; 195 196 case SIGUSR1: 197 CNF(sig_usr1) = 1; 198 break; 166 199 } 167 200 } … … 181 214 if (sigaction(SIGHUP, &sa, NULL) == -1) 182 215 log_msg(LOG_ERR, "could not install SIGHUP handler: \"%s\"", strerror(errno)), exit(1); 216 if (sigaction(SIGUSR1, &sa, NULL) == -1) 217 log_msg(LOG_ERR, "could not install SIGUSR1 handler: \"%s\"", strerror(errno)), exit(1); 183 218 } 184 219 … … 187 222 { 188 223 OcatPeer_t *peer, *next; 224 char c; 189 225 190 226 log_msg(LOG_NOTICE, "waiting for system cleanup..."); … … 227 263 delete_listeners(CNF(oc_listen), CNF(oc_listen_fd), CNF(oc_listen_cnt)); 228 264 229 if (CNF(create_pid_file) && (unlink(CNF(pid_file)) == -1)) 230 log_msg(LOG_ERR, "could not remove pid file \"%s\": %s", CNF(pid_file), strerror(errno)); 265 if (CNF(create_pid_file) && (CNF(pid_fd[1]) != -1)) 266 { 267 if (write(CNF(pid_fd[1]), &c, 1) == -1) 268 log_msg(LOG_ERR, "cout not write to pid fd %d: \"%s\"", CNF(pid_fd[1]), strerror(errno)); 269 } 231 270 } 232 271 -
trunk/src/ocat.h
r534 r535 200 200 //! RECONN_ATTEMPTS must not be faster than MIN_RECONNECT_TIME 201 201 #define MIN_RECONNECT_TIME 30 202 //! define default maximum number of concurrent controller sessions 203 #define MAX_DEF_CTRL_SESS 5 202 204 203 205 #define MFD_SET(f,s,m) {FD_SET(f, s); m = f > m ? f : m;} … … 213 215 #define VERSION_STRING_LEN 256 214 216 217 #define MAX_DEF_CTRL 6 215 218 216 219 #define NTYPE_TOR 0 … … 292 295 int socksfd[2]; 293 296 int net_type; 297 int max_ctrl, ctrl_active; 298 //! pipe filedescriptors for pid deletion process 299 int pid_fd[2]; 300 int sig_usr1, clear_stats; 294 301 }; 295 302 -
trunk/src/ocatctrl.c
r534 r535 75 75 //CNF(config_read) = 1; 76 76 } 77 78 lock_setup(); 79 CNF(ctrl_active)++; 80 unlock_setup(); 77 81 78 82 fprintf(fo, "%s\n", CNF(version)); … … 303 307 oe_close(pfd[1]); 304 308 309 lock_setup(); 310 CNF(ctrl_active)--; 311 unlock_setup(); 312 305 313 return NULL; 306 314 } … … 309 317 int run_ctrl_handler(int fd) 310 318 { 319 // check number of controller sessions 320 // FIXME: listener should be closed or acceptor delayed instead of 321 // counting after session acceptance. 322 lock_setup(); 323 if (CNF(ctrl_active) >= CNF(max_ctrl)) 324 { 325 log_msg(LOG_WARNING, "maximum number of controller sessions reached"); 326 oe_close(fd); 327 fd = -1; 328 } 329 unlock_setup(); 330 if (fd == -1) 331 return -1; 332 311 333 return (int) run_ocat_thread("ctrl_handler", ctrl_handler, (void*) (long) fd); 312 334 } -
trunk/src/ocatlibe.c
r534 r535 142 142 struct sockaddr_in6 saddr; 143 143 144 if (strsockaddr(buf, &saddr) == -1)144 if (strsockaddr(buf, (struct sockaddr*) &saddr) == -1) 145 145 log_msg(LOG_EMERG, "could not convert address string '%s'", buf), exit(1); 146 146 -
trunk/src/ocatroute.c
r500 r535 631 631 { 632 632 int family; 633 int fd ;633 int fd, so; 634 634 635 635 switch (addr->sa_family) … … 652 652 } 653 653 654 so = 1; 655 if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &so, sizeof(so)) == -1) 656 log_msg(LOG_WARNING, "could not set socket %d to SO_REUSEADDR: \"%s\"", fd, strerror(errno)); 654 657 if (bind(fd, addr, sock_len) == -1) 655 658 { … … 822 825 set_term_req(); 823 826 } 827 if (CNF(sig_usr1)) 828 { 829 lock_setup(); 830 CNF(clear_stats) = 1; 831 unlock_setup(); 832 log_msg(LOG_NOTICE, "stats will be cleared after next stats output"); 833 } 824 834 } 825 835 log_debug("restarting"); … … 965 975 stat_wup = act_time; 966 976 log_msg(LOG_INFO, "stats: ... (not implemented yet)"); 977 978 lock_setup(); 979 if (CNF(clear_stats)) 980 { 981 CNF(clear_stats) = 0; 982 // FIXME: implement stats clearing here 983 log_debug("stats cleared"); 984 } 985 unlock_setup(); 967 986 } 968 987 -
trunk/src/ocatsetup.c
r534 r535 113 113 {-1, -1}, 114 114 // net_type 115 NTYPE_TOR 115 NTYPE_TOR, 116 // max_ctrl, ctrl_active 117 MAX_DEF_CTRL_SESS, 0, 118 // pid_fd 119 {-1, -1}, 120 // sig_usr1, clear_stats 121 0, 0 116 122 }; 117 123 … … 131 137 //setup_.logf = stderr; 132 138 setup_.uptime = time(NULL); 139 memset(&socks_dst6_, 0, sizeof(socks_dst6_)); 140 setup_.socks_dst->sin_family = AF_INET; 141 setup_.socks_dst->sin_addr.s_addr = htonl(INADDR_LOOPBACK); 142 #ifdef HAVE_SIN_LEN 143 setup_.socks_dst->sin_len = SOCKADDR_SIZE(setup_.socks_dst); 144 #endif 133 145 } 134 146 … … 141 153 setup_.ocat_ctrl_port = NDESC(ctrl_port); 142 154 143 setup_.socks_dst->sin_family = AF_INET; 144 setup_.socks_dst->sin_port = htons(NDESC(socks_port)); 145 setup_.socks_dst->sin_addr.s_addr = htonl(INADDR_LOOPBACK); 146 #ifdef HAVE_SIN_LEN 147 setup_.socks_dst->sin_len = SOCKADDR_SIZE(setup_.socks_dst); 148 #endif 155 if (!setup_.socks_dst->sin_port) 156 setup_.socks_dst->sin_port = htons(NDESC(socks_port)); 149 157 150 158 ctrl_listen_.sin_family = AF_INET; … … 227 235 "term_req = %d\n" 228 236 "net_type = %d (%s)\n" 237 "max_ctrl = %d\n" 238 "ctrl_active = %d\n" 239 "pid_fd[2] = {%d, %d}\n" 240 "clear_stats = %d\n" 229 241 , 230 242 IPV4_KEY, ntohl(setup_.fhd_key[IPV4_KEY]), IPV6_KEY, ntohl(setup_.fhd_key[IPV6_KEY]), … … 260 272 setup_.sizeof_setup, 261 273 setup_.term_req, 262 setup_.net_type, setup_.net_type == NTYPE_TOR ? "NTYPE_TOR" : setup_.net_type == NTYPE_I2P ? "NTYPE_I2P" : "unknown" 274 setup_.net_type, setup_.net_type == NTYPE_TOR ? "NTYPE_TOR" : setup_.net_type == NTYPE_I2P ? "NTYPE_I2P" : "unknown", 275 setup_.max_ctrl, setup_.ctrl_active, 276 setup_.pid_fd[0], setup_.pid_fd[1], 277 setup_.clear_stats 263 278 ); 264 279
Note: See TracChangeset
for help on using the changeset viewer.
