Open bugsyb opened 4 years ago
Root cause is that currently there is IPv6 address included on status output, hence need to skip it (or map to new table field - skipping it in my case:
diff -Naur openvpn-web-ui-orig/vendor/github.com/adamwalach/go-openvpn/server/mi/parse.go openvpn-web-ui-override/vendor/github.com/adamwalach/go-openvpn/server/mi/parse.go
--- openvpn-web-ui-orig/vendor/github.com/adamwalach/go-openvpn/server/mi/parse.go 2020-03-22 14:02:56.000000000 +0100
+++ openvpn-web-ui-override/vendor/github.com/adamwalach/go-openvpn/server/mi/parse.go 2020-11-12 23:37:01.000000000 +0100
@@ -88,17 +88,17 @@
}
s.RoutingTable = append(s.RoutingTable, item)
case c == "CLIENT_LIST":
- bytesR, _ := strconv.ParseUint(fields[4], 10, 64)
- bytesS, _ := strconv.ParseUint(fields[5], 10, 64)
+ bytesR, _ := strconv.ParseUint(fields[5], 10, 64)
+ bytesS, _ := strconv.ParseUint(fields[6], 10, 64)
item := &OVClient{
CommonName: fields[1],
RealAddress: fields[2],
VirtualAddress: fields[3],
BytesReceived: bytesR,
BytesSent: bytesS,
- ConnectedSince: fields[6],
- ConnectedSinceT: fields[7],
- Username: fields[8],
+ ConnectedSince: fields[7],
+ ConnectedSinceT: fields[8],
+ Username: fields[9],
}
s.ClientList = append(s.ClientList, item)
}
Output:
status 2
TITLE,OpenVPN 2.4.9 aarch64-alpine-linux-musl [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [MH/PKTINFO] [AEAD] built on Apr 20 2020
TIME,Thu Nov 12 22:06:53 2020,1605218813
HEADER,CLIENT_LIST,Common Name,Real Address,Virtual Address,Virtual IPv6 Address,Bytes Received,Bytes Sent,Connected Since,Connected Since (time_t),Username,Client ID,Peer ID
Pending fix to be applied, pls.
Hi Adam,
Would you be able please kindly to fix the little problem with mapping fields? [https://imgur.com/a/c9GBERj]
The KB received shows 0, the KB Sent shows value, in fact received in KBytes, Connected Since shows Sent but in B not KB, and Username shows connected since but in timestamp, not date.
Belief is that it is down to parse.go section (below is what I thought would fix it - but something is wrong with this - not sure why field[4] gets 0, hence moved on to next field.
https://github.com/adamwalach/openvpn-web-ui/blob/075614837fd082481d3c29bf61aded7079b9f1e4/vendor/github.com/adamwalach/go-openvpn/server/mi/parse.go#L91
Hope this is a 1 minute issue for you to fix.
Thank you in advance.