- 
                Notifications
    
You must be signed in to change notification settings  - Fork 63
 
add support for proxy_connect module #43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 
          
            
          
           | 
    @@ -640,6 +640,32 @@ ngx_http_auth_digest_verify_hash(ngx_http_request_t *r, | |||||||||||||||||||||||||||||||||
| ngx_md5_t md5; | ||||||||||||||||||||||||||||||||||
| u_char hash[16]; | ||||||||||||||||||||||||||||||||||
| 
     | 
||||||||||||||||||||||||||||||||||
| #ifdef NGX_HTTP_PROXY_CONNECT | ||||||||||||||||||||||||||||||||||
| if (r->method_name.len == 7 && ngx_strncmp(r->method_name.data, "CONNECT", 7) == 0) { | ||||||||||||||||||||||||||||||||||
| // CONNECT requests don't have `r->unparsed_uri` set, so the URI must be validated | ||||||||||||||||||||||||||||||||||
| // against server address (& optionally port) | ||||||||||||||||||||||||||||||||||
| size_t uri_len = 0; | ||||||||||||||||||||||||||||||||||
| while (uri_len < fields->uri.len && fields->uri.data[uri_len++] != ':'); | ||||||||||||||||||||||||||||||||||
| if (uri_len < fields->uri.len && fields->uri.data[uri_len] == ':') { | ||||||||||||||||||||||||||||||||||
| uri_len--; | ||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||
| if (!((r->connect_host.len == (uri_len - 1)) && | ||||||||||||||||||||||||||||||||||
| (ngx_strncmp(r->connect_host.data, fields->uri.data, | ||||||||||||||||||||||||||||||||||
| uri_len) == 0))) { | ||||||||||||||||||||||||||||||||||
                
       | 
||||||||||||||||||||||||||||||||||
| size_t uri_len = 0; | |
| while (uri_len < fields->uri.len && fields->uri.data[uri_len++] != ':'); | |
| if (uri_len < fields->uri.len && fields->uri.data[uri_len] == ':') { | |
| uri_len--; | |
| } | |
| if (!((r->connect_host.len == (uri_len - 1)) && | |
| (ngx_strncmp(r->connect_host.data, fields->uri.data, | |
| uri_len) == 0))) { | |
| size_t colon_pos = 0; | |
| while (colon_pos < fields->uri.len && fields->uri.data[colon_pos] != ':') { | |
| colon_pos++; | |
| } | |
| size_t host_len = colon_pos; // Host segment length is up to the colon | |
| if (!((r->connect_host.len == host_len) && | |
| (ngx_strncmp(r->connect_host.data, fields->uri.data, | |
| host_len) == 0))) { | 
        
          
              
                Outdated
          
        
      
    
      
    
      Copilot
AI
    
    
    
      Jun 27, 2025 
    
  
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The condition uses uri_port_len != r->connect_port.len combined with && and negated, but it should reject if lengths differ OR contents differ. Replace with:
if (uri_port_len != r->connect_port.len
    || ngx_strncmp(uri_port, r->connect_port.data, uri_port_len) != 0) {
    return NGX_DECLINED;
}
| if (!((uri_port_len != r->connect_port.len) && | |
| (ngx_strncmp(uri_port, r->connect_port.data, ngx_min(uri_port_len, r->connect_port.len)) == 0))) { | |
| if (uri_port_len != r->connect_port.len || | |
| ngx_strncmp(uri_port, r->connect_port.data, uri_port_len) != 0) { | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of comparing
r->method_namebytes, consider using the NGINX request method enum (r->method == NGX_HTTP_CONNECT) for clarity and to avoid string comparisons.