<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content="text/html; charset=iso-8859-1" http-equiv=Content-Type>
<META name=GENERATOR content="MSHTML 8.00.6001.18702">
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT size=2 face=Arial>Pegando o bonde andando....</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>Mem desculpe, para pegar o ip do cliente, não pode 
ser feito assim ?</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial>my $ip_cliente=$ENV{REMOTE_ADDR};</FONT></DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV><FONT size=2 face=Arial></FONT> </DIV>
<DIV>Ricardo Stock<BR><A 
href="http://www.stocksistemas.com.br">www.stocksistemas.com.br</A><BR></DIV>
<BLOCKQUOTE 
style="BORDER-LEFT: #000000 2px solid; PADDING-LEFT: 5px; PADDING-RIGHT: 0px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px">
  <DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
  <DIV 
  style="FONT: 10pt arial; BACKGROUND: #e4e4e4; font-color: black"><B>From:</B> 
  <A title=shonorio@gmail.com href="mailto:shonorio@gmail.com">Solli Honorio</A> 
  </DIV>
  <DIV style="FONT: 10pt arial"><B>To:</B> <A title=saopaulo-pm@mail.pm.org 
  href="mailto:saopaulo-pm@mail.pm.org">saopaulo-pm@mail.pm.org</A> </DIV>
  <DIV style="FONT: 10pt arial"><B>Sent:</B> Wednesday, September 19, 2012 9:49 
  PM</DIV>
  <DIV style="FONT: 10pt arial"><B>Subject:</B> Re: [SP-pm] Mojolicious Daemon e 
  Client em JSON</DIV>
  <DIV><BR></DIV>Nilson,
  <DIV><BR></DIV>
  <DIV>Você pode pegar o ip do cliente através de 
  $self->tx->remote_address, como no exemplo abaixo :</DIV>
  <DIV><BR></DIV>
  <DIV><PRE style="BORDER-BOTTOM: rgb(136,136,136) 1px solid; BORDER-LEFT: rgb(136,136,136) 1px solid; PADDING-BOTTOM: 1em; BACKGROUND-COLOR: rgb(238,238,238); PADDING-LEFT: 1em; PADDING-RIGHT: 1em; BORDER-TOP: rgb(136,136,136) 1px solid; BORDER-RIGHT: rgb(136,136,136) 1px solid; PADDING-TOP: 1em" class="sh_perl sh_sourceCode">
<SPAN class=sh_keyword>use</SPAN> Mojolicious<SPAN class=sh_symbol>::</SPAN>Lite<SPAN class=sh_symbol>;</SPAN>

  <SPAN class=sh_comment># "whois" helper</SPAN>
  helper whois <SPAN class=sh_symbol>=></SPAN> <SPAN class=sh_keyword>sub</SPAN> <SPAN class=sh_cbracket>{</SPAN>
    <SPAN class=sh_keyword>my</SPAN> <SPAN class=sh_variable>$self</SPAN>  <SPAN class=sh_symbol>=</SPAN> <SPAN class=sh_keyword>shift</SPAN><SPAN class=sh_symbol>;</SPAN>
    <SPAN class=sh_keyword>my</SPAN> <SPAN class=sh_variable>$agent</SPAN> <SPAN class=sh_symbol>=</SPAN> <SPAN class=sh_variable>$self</SPAN><SPAN class=sh_symbol>-></SPAN>re<SPAN class=sh_keyword>q</SPAN><SPAN class=sh_string>->headers-</SPAN><SPAN class=sh_symbol>></SPAN>user_agent <SPAN class=sh_symbol>||</SPAN> <SPAN class=sh_string>'Anonymous'</SPAN><SPAN class=sh_symbol>;</SPAN>
    <SPAN class=sh_keyword>my</SPAN> <SPAN class=sh_variable>$ip</SPAN>    <SPAN class=sh_symbol>=</SPAN> <SPAN class=sh_variable>$self</SPAN><SPAN class=sh_symbol>-></SPAN>tx<SPAN class=sh_symbol>-></SPAN>remote_address<SPAN class=sh_symbol>;</SPAN>
    <SPAN class=sh_keyword>return</SPAN> <SPAN class=sh_string>"$agent ($ip)"</SPAN><SPAN class=sh_symbol>;</SPAN>
  <SPAN class=sh_cbracket>}</SPAN><SPAN class=sh_symbol>;</SPAN>

  <SPAN class=sh_comment># /secret</SPAN>
  get <SPAN class=sh_string>'/secret'</SPAN> <SPAN class=sh_symbol>=></SPAN> <SPAN class=sh_keyword>sub</SPAN> <SPAN class=sh_cbracket>{</SPAN>
    <SPAN class=sh_keyword>my</SPAN> <SPAN class=sh_variable>$self</SPAN> <SPAN class=sh_symbol>=</SPAN> <SPAN class=sh_keyword>shift</SPAN><SPAN class=sh_symbol>;</SPAN>
    <SPAN class=sh_keyword>my</SPAN> <SPAN class=sh_variable>$user</SPAN> <SPAN class=sh_symbol>=</SPAN> <SPAN class=sh_variable>$self</SPAN><SPAN class=sh_symbol>-></SPAN>whois<SPAN class=sh_symbol>;</SPAN>
    <SPAN class=sh_variable>$self</SPAN><SPAN class=sh_symbol>-></SPAN>app<SPAN class=sh_symbol>-></SPAN><SPAN class=sh_keyword>log</SPAN><SPAN class=sh_symbol>-></SPAN><SPAN class=sh_function>debug</SPAN><SPAN class=sh_symbol>(</SPAN><SPAN class=sh_string>"Request from $user."</SPAN><SPAN class=sh_symbol>);</SPAN>
  <SPAN class=sh_cbracket>}</SPAN><SPAN class=sh_symbol>;</SPAN>

  app<SPAN class=sh_symbol>-></SPAN>start<SPAN class=sh_symbol>;</SPAN>
  __DATA__

  @@ secret<SPAN class=sh_symbol>.</SPAN>html<SPAN class=sh_symbol>.</SPAN>ep
  We know who you are <SPAN class=sh_string><%= whois %></SPAN><SPAN class=sh_symbol>.</SPAN></PRE><BR>
  <DIV class=gmail_quote>Em 12 de setembro de 2012 22:23, Jose Nilton <SPAN 
  dir=ltr><<A href="mailto:jniltinho@gmail.com" 
  target=_blank>jniltinho@gmail.com</A>></SPAN> escreveu:<BR>
  <BLOCKQUOTE 
  style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" 
  class=gmail_quote>Nelson, obrigado<BR><BR>Desculpe só responder o e-mail 
    agora, tive uns contratempos de infra aqui<BR></BLOCKQUOTE></DIV><BR><BR 
  clear=all>
  <DIV><BR></DIV>-- <BR>"o animal satisfeito dorme". - Guimarães Rosa<BR></DIV>
  <P>
  <HR>

  <P></P>=begin disclaimer<BR>   Sao Paulo Perl Mongers: 
  http://sao-paulo.pm.org/<BR> SaoPaulo-pm mailing list: 
  SaoPaulo-pm@pm.org<BR> L<http://mail.pm.org/mailman/listinfo/saopaulo-pm><BR>=end 
  disclaimer<BR></BLOCKQUOTE></BODY></HTML>