Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Status fields mapping - simple fix #29

Open
bugsyb opened this issue Nov 12, 2020 · 2 comments
Open

Status fields mapping - simple fix #29

bugsyb opened this issue Nov 12, 2020 · 2 comments

Comments

@bugsyb
Copy link

bugsyb commented Nov 12, 2020

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.

		case c == "CLIENT_LIST":
			bytesR, _ := strconv.ParseUint(fields[5], 10, 64)
			bytesS, _ := strconv.ParseUint(fields[6], 10, 64)
//			ConnectedSinceD := time.Unix(fields[7])
			item := &OVClient{
				CommonName:      fields[1],
				RealAddress:     fields[2],
				VirtualAddress:  fields[3],
				BytesReceived:   bytesR,
				BytesSent:       bytesS,
				ConnectedSince:  fields[7],
				ConnectedSinceT: fields[8],
//				Username:        fields[9],

bytesR, _ := strconv.ParseUint(fields[4], 10, 64)

Hope this is a 1 minute issue for you to fix.

Thank you in advance.

@bugsyb
Copy link
Author

bugsyb commented Nov 12, 2020

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

@bugsyb bugsyb closed this as completed Nov 12, 2020
@bugsyb bugsyb reopened this Nov 12, 2020
@bugsyb
Copy link
Author

bugsyb commented Nov 12, 2020

Pending fix to be applied, pls.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant