5725149546
The user's OpenVPN 2.5.11 outputs CLIENT_LIST with 13 tab-separated
fields:
CLIENT_LIST CN RealAddr VPNAddr IPv6(empty) (empty) BytesRecv
BytesSent ConnectedSince (time_t) Username ClientID
PeerID Cipher
But OpenVPN 2.6+ drops the IPv6 and Cipher fields (11 columns), and
some versions include 'Connected Since (time_t)' which moves all
positions.
Solution: parse by content type, not position:
- parts[0] = 'CLIENT_LIST'
- parts[1] = CN (string, may be empty)
- parts[2] = RealAddr (string with ':')
- parts[3] = VPNAddr (IP, may be empty)
- parts[4..] = scan for first pure-numeric field → BytesRecv
- BytesRecv+1 = BytesSent
- BytesRecv+2 = ConnectedSince
Verified against the user's real status.log:
CN=test RealAddr=123.118.73.196:17564 VPNAddr=10.8.0.2
bytesIn=629025 bytesOut=539217