diff options
Diffstat (limited to 'opentracker.c')
| -rw-r--r-- | opentracker.c | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/opentracker.c b/opentracker.c index 9cdc68e..c1fe945 100644 --- a/opentracker.c +++ b/opentracker.c | |||
| @@ -122,6 +122,24 @@ static void help( char *name ) { | |||
| 122 | } | 122 | } |
| 123 | #undef HELPLINE | 123 | #undef HELPLINE |
| 124 | 124 | ||
| 125 | static size_t header_complete( char * request, ssize_t byte_count ) { | ||
| 126 | int i = 0, state = 0; | ||
| 127 | |||
| 128 | for( i=1; i < byte_count; i+=2 ) | ||
| 129 | if( request[i] <= 13 ) { | ||
| 130 | i--; | ||
| 131 | for( state = 0 ; i < byte_count; ++i ) { | ||
| 132 | char c = request[i]; | ||
| 133 | if( c == '\r' || c == '\n' ) | ||
| 134 | state = ( state >> 2 ) | ( ( c << 6 ) & 0xc0 ); | ||
| 135 | else | ||
| 136 | break; | ||
| 137 | if( state >= 0xa0 || state == 0x99 ) return i + 1; | ||
| 138 | } | ||
| 139 | } | ||
| 140 | return 0; | ||
| 141 | } | ||
| 142 | |||
| 125 | static void handle_dead( const int64 sock ) { | 143 | static void handle_dead( const int64 sock ) { |
| 126 | struct http_data* cookie=io_getcookie( sock ); | 144 | struct http_data* cookie=io_getcookie( sock ); |
| 127 | if( cookie ) { | 145 | if( cookie ) { |
| @@ -330,8 +348,8 @@ static int scan_ip6_port( const char *src, ot_ip6 ip, uint16 *port ) { | |||
| 330 | if( bracket && *s == ']' ) ++s; | 348 | if( bracket && *s == ']' ) ++s; |
| 331 | if( *s == 0 || isspace(*s)) return s-src; | 349 | if( *s == 0 || isspace(*s)) return s-src; |
| 332 | if( !ip6_isv4mapped(ip)){ | 350 | if( !ip6_isv4mapped(ip)){ |
| 333 | if( *s != ':' && *s != '.' ) return 0; | 351 | if( *s != ':' && *s != '.' ) return 0; |
| 334 | if( !bracket && *(s) == ':' ) return 0; | 352 | if( !bracket && *(s) == ':' ) return 0; |
| 335 | s++; | 353 | s++; |
| 336 | } else { | 354 | } else { |
| 337 | if( *(s++) != ':' ) return 0; | 355 | if( *(s++) != ':' ) return 0; |
