<div dir="ltr"><div>> Reading that file, the next likely looking line is:</div><div>> c->addr_text.len = ngx_sock_ntop(c->sockaddr, c->socklen,</div><div>> c->addr_text.data,</div><div>> ls->addr_text_max_len, 0);</div><div><br></div><div>Thank you for the boost. From what you said, it looks like the variable is constructed from c->sockaddr</div><div><br></div><div>src/event/ngx_event_accept.c<br></div><div>line 167<br></div><div>c->sockaddr = ngx_palloc(c->pool, socklen);<br></div><div><br></div><div>I chased that down, and it looks like ngx_palloc only allocates some memory; it doesn't fill it. Moving on.</div><div><br></div><div><div>line 173</div><div>ngx_memcpy(c->sockaddr, &sa, socklen);</div></div><div><br></div><div>It looks like ngx_memcpy is a wrapper around the standard C library function memcpy. For memcpy(A, B, C), it copies to destination A from source B, and it does amount C. So now I want to know where &sa comes from.</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra">line 70</div><div class="gmail_extra">s = accept(lc->fd, &sa.sockaddr, &socklen);</div><div class="gmail_extra"><br></div><div class="gmail_extra">Here, &sa.sockaddr is being sent into something. I think &sa.sockaddr becomes c->sockaddr, so I chase this.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Bash</div><div class="gmail_extra">man 2 accept<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">accept is a Linux system call: "accept a connection on a socket"</div><div class="gmail_extra">int accept(int sockfd, struct sockaddr *addr, socklen_t *addrlen);<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">"The argument addr is a pointer to a sockaddr structure. This</div><div class="gmail_extra">structure is filled in with the address of the peer socket, as known</div><div class="gmail_extra">to the communications layer. The exact format of the address</div><div class="gmail_extra">returned addr is determined by the socket's address family (see</div><div class="gmail_extra">socket(2) and the respective protocol man pages). When addr is NULL,</div><div class="gmail_extra">nothing is filled in; in this case, addrlen is not used, and should</div><div class="gmail_extra">also be NULL."</div><div class="gmail_extra"><br></div><div class="gmail_extra">And so, the answer to my question appears to be: $remote_addr is constructed from "struct sockaddr *addr" of the "accept" Linux system call. It is the address of the peer socket.</div><div class="gmail_extra"><br></div><div class="gmail_extra">I am going to read through socket(2) and the respective protocol man pages, but at this point we're outside of NGINX, and so the scope of this mailing list.</div><div class="gmail_extra">Thank you again for your help.</div><div class="gmail_extra"><br></div><div class="gmail_extra"> ~ Paul Nickerson</div></div></div>
<br>
<div><div><span style="border-collapse:collapse"><p style="margin-top:0px;margin-right:0in;margin-bottom:5pt;margin-left:0in"><span style="font-size:7.5pt"><font color="#666666" face="tahoma, sans-serif"><b>CONFIDENTIALITY NOTICE</b></font></span></p></span></div></div><div><span style="border-collapse:collapse"><p><span style="color:rgb(102,102,102);font-family:tahoma,sans-serif;font-size:10px">The attached information is PRIVILEGED AND CONFIDENTIAL and is intended only for the use of the addressee named above. If the reader of this message is not the intended recipient or the employee or agent responsible for delivering the message to the intended recipient, please be aware that any dissemination, distribution or duplication of this communication is strictly prohibited. If you receive this communication in error, please notify us immediately by telephone, delete the message and destroy any printed copy of the message. Thank you.</span></p></span></div>