Development discussion of WireGuard
 help / color / mirror / Atom feed
* Structure(d) output of wg?
@ 2016-12-14 20:04 Dan Lüdtke
  2016-12-14 21:09 ` Jason A. Donenfeld
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Lüdtke @ 2016-12-14 20:04 UTC (permalink / raw)
  To: Jason A. Donenfeld; +Cc: WireGuard mailing list

Hi Jason, everyone,

I'd like to discuss the topic of structured output. I am working on =
luci-app-wireguard* which aims to provide status information via the =
user-friendly LUCI interface in LEDE. While writing code to parse the =
output I realized that I may not be the only one who needs to structure =
wg's output. Would it make sense to add support for structured output =
now and thus prevent/reduce parsers and half-baked solutions popping up =
in higher level software in the future?

Something like wg show --json
[
	{
		interface: "foo"
		private_key: "(hidden)",
		preshared_key: "(hidden)",
		listen_port: "12345",
		peers: [
			{
				public_key: "dfkdjkfjslfkd...",
				bandwith: "...",
				last_handshake: "..."
			},
			{
				public_key: "sdj9ad....",
				allowed_ips: "2001:db8::/64",
				bandwith: "..."
			}
		]
	},
	{
		interface: "foo2",
		...you get the idea...
	}
]

JSON is just one idea because it allows nice structuring. CSV, TSV or =
whatever is lean and easy to implement may be an equally good option. =
While structuring, we could also provide even more structure than the =
usual stdout of wg provides. Candidate for lists: allowed_ips
Candidate for sub-structures: bandwith (rx, tx)

What do you think?

Cheers,

Dan


*: Not to be confused with luci-proto-wireguard, kmod-wireguard, and =
wireguard-tools. They provide functionality and configuration =
interfaces, but not monitoring/fancy output.=

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Structure(d) output of wg?
  2016-12-14 20:04 Structure(d) output of wg? Dan Lüdtke
@ 2016-12-14 21:09 ` Jason A. Donenfeld
  2016-12-14 21:16   ` Dan Lüdtke
  0 siblings, 1 reply; 4+ messages in thread
From: Jason A. Donenfeld @ 2016-12-14 21:09 UTC (permalink / raw)
  To: Dan Lüdtke; +Cc: WireGuard mailing list

Hi Dan,

This already exists. While `wg show wg0` gives some hipster colorized
output, `wg show wg0 [CATEGORY]` gives very structured output meant
for parsing with bash or grep or sed or cut or whatever you want. For
example:

[zx2c4@demo ~]$ sudo wg show wg0 bandwidth | tail
l8gKhi5rvJChhDWHl+C7Ubj8hSHfW0HbkOOA9GQPL3Y=    13272   43056
CpX3sUNoLSofE6V6X+uHnFqF5+g/fXwJeY6ploPbgV0=    9425    5785
NkUUqbqhh+VV2IZYdAuVIdjpx0UopRRgO7hZju7+DW0=    145     89
S3/UokM7yvoKCYOvGdyi0IiiqvrUWXsIX8FTSFl0i2E=    46101   152415
FPqY/W8Z6LTgZLu69CqF1WtIPwUoG52pNNno4BRDtR0=    145     89
ULFNzzUznzXzMrjRvWUlz9dQsIzEAtIG7o3s9oHRJHk=    145     89
qbTrp7yhdqrvLnMg9kZNxNTd7FQRvV6jMr18G63zDhA=    13299   28787
p0rDK1UEx7siGp061hekJFYkjTs3qY08TBaTfSk86TM=    5075    3434
NZSZ7/JTraQ6eOseLIMQBo38cfQL8SXarfO/g99xYUI=    0       0
pX7cS/weolOD5GKHhrNqtqKT4nZto50ZXczacQ5iklM=    95210   58850

(Quit hoggin my bandwidth, yall ;-) )

Jason

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Structure(d) output of wg?
  2016-12-14 21:16   ` Dan Lüdtke
@ 2016-12-14 21:15     ` Jason A. Donenfeld
  0 siblings, 0 replies; 4+ messages in thread
From: Jason A. Donenfeld @ 2016-12-14 21:15 UTC (permalink / raw)
  To: Dan Lüdtke; +Cc: WireGuard mailing list

Hey Dan,

Yea, but that's usually the case with command line tools and shell
processing. If you're in a position to be calling json, then why not
just also call the ioctl directly? I guess json might be easier for
some consumers? Hmm...

> Nice bandwidth, though :)

That's just the first ten too...
[zx2c4@demo ~]$ sudo wg show wg0 peers | wc -l
232

Jason

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Structure(d) output of wg?
  2016-12-14 21:09 ` Jason A. Donenfeld
@ 2016-12-14 21:16   ` Dan Lüdtke
  2016-12-14 21:15     ` Jason A. Donenfeld
  0 siblings, 1 reply; 4+ messages in thread
From: Dan Lüdtke @ 2016-12-14 21:16 UTC (permalink / raw)
  To: Jason A. Donenfeld; +Cc: WireGuard mailing list

Hi,

that would mean multiple calls to `wg` to get the desired structure =
filled, one for each [CATEGORY]. I can live with that, but was looking =
for a more efficient solution.

Cheers,

Dan

Nice bandwidth, though :)
=20
> On 14 Dec 2016, at 22:09, Jason A. Donenfeld <Jason@zx2c4.com> wrote:
>=20
> Hi Dan,
>=20
> This already exists. While `wg show wg0` gives some hipster colorized
> output, `wg show wg0 [CATEGORY]` gives very structured output meant
> for parsing with bash or grep or sed or cut or whatever you want. For
> example:
>=20
> [zx2c4@demo ~]$ sudo wg show wg0 bandwidth | tail
> l8gKhi5rvJChhDWHl+C7Ubj8hSHfW0HbkOOA9GQPL3Y=3D    13272   43056
> CpX3sUNoLSofE6V6X+uHnFqF5+g/fXwJeY6ploPbgV0=3D    9425    5785
> NkUUqbqhh+VV2IZYdAuVIdjpx0UopRRgO7hZju7+DW0=3D    145     89
> S3/UokM7yvoKCYOvGdyi0IiiqvrUWXsIX8FTSFl0i2E=3D    46101   152415
> FPqY/W8Z6LTgZLu69CqF1WtIPwUoG52pNNno4BRDtR0=3D    145     89
> ULFNzzUznzXzMrjRvWUlz9dQsIzEAtIG7o3s9oHRJHk=3D    145     89
> qbTrp7yhdqrvLnMg9kZNxNTd7FQRvV6jMr18G63zDhA=3D    13299   28787
> p0rDK1UEx7siGp061hekJFYkjTs3qY08TBaTfSk86TM=3D    5075    3434
> NZSZ7/JTraQ6eOseLIMQBo38cfQL8SXarfO/g99xYUI=3D    0       0
> pX7cS/weolOD5GKHhrNqtqKT4nZto50ZXczacQ5iklM=3D    95210   58850
>=20
> (Quit hoggin my bandwidth, yall ;-) )
>=20
> Jason

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-12-14 21:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-14 20:04 Structure(d) output of wg? Dan Lüdtke
2016-12-14 21:09 ` Jason A. Donenfeld
2016-12-14 21:16   ` Dan Lüdtke
2016-12-14 21:15     ` Jason A. Donenfeld

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).