I looked around a bit and haven’t found a way for a non commercial user to open 
a change request with openvpn team, please point me out if I’m wrong.

for reference, this is how to determine the server IP using conntrack(8)

ovpnport=5001
remoteip=1.2.3.4
sudo conntrack -L -s $remoteip -p udp -o extended 2> /dev/null | fgrep 
dport=$ovpnport | sed -E 's/.*src=(.*) dst=.*/\1/'

or you could go straight to /proc if you don’t feel like installing conntrack

sudo fgrep $remoteip /proc/net/nf_conntrack | fgrep dport=$ovpnport | tail -1 | 
sed -E 's/.*src=(.*) dst=.*/\1/'


> On 7. Jun 2021, at 21:35, Gert Doering <g...@greenie.muc.de> wrote:
> 
> Hi,
> 
> On Fri, Jun 04, 2021 at 12:55:04PM +0200, Gert Doering wrote:
>> That said, I have no idea if it is ever exposed to management API or
>> plugin/script env... "some reading of the source" is needed.
> 
> So.  "OpenVPN side" address is only available if ENABLE_IP_PKTINFO
> is valid, and then it can be found in the "link_socket_actual" structure
> in act->pi.in4 / act->pi.in4.ip_spec_dst / act->pi.in6.ipi6_addr, see
> socket.c, print_link_socket_actual_ex().
> 
> The most interesting caller of this seems to be linksock_print_addr(),
> which is called at the end of link_socket_init_phase2().
> 
> 
> The incoming source address is setenv'ed by 
> 
> tls_process()
>  link_socket_set_outgoing_addr()
>    link_socket_connection_initiated()
>      setenv_trusted()
>        setenv_link_socket_actual()
>          setenv_sockaddr()
> 
> ... so that would be the call chain where one could add a "this is 
> the local address used" setenv() call, similar to what 
> print_link_socket_actual_ex() does.
> 
> Good practice might be to extract the whole "local address" part of
> print_link_socket_actual_ex() into a new subfunction used for both
> cases (= less code duplication, less testing).  But this is still not 
> a totally trivial task.
> 
> gert
> 
> -- 
> "If was one thing all people took for granted, was conviction that if you 
> feed honest figures into a computer, honest figures come out. Never doubted 
> it myself till I met a computer with a sense of humor."
>                             Robert A. Heinlein, The Moon is a Harsh Mistress
> 
> Gert Doering - Munich, Germany                             g...@greenie.muc.de




_______________________________________________
Openvpn-users mailing list
Openvpn-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openvpn-users

Reply via email to