[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#965259: x2goserver: optimized get_server_ip_address()



Package: x2goserver
Version: 4.1.0.3-5
Severity: minor

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512

Hi,

Just stumbled upon the function get_server_ip_address()
in file x2goserver/lib/x2gogetrandomport,
and noticed that it is unnecessarily elaborate.

The whole function can be reduced to this:

  ip route get 8.8.8.8 | grep -Poqe 'src\s+\K((\d{1,3}\.){3}\d{1,3})'

I.e. there is no need to store response from "ip route get",
it can be parsed directly via a pipe,
and there is no need to parse first with grep and then with sed,
or to separately examine if result of parsing is non-empty,
that can all be done with grep
using a shorter and arguably more readable pcre regex.

Please consider passing this suggestion upstream.

(not doing it myself: too much work subscribing to yet another mailinglist and then seemingly also needing to go through extra hoops related to GDPR, for this small suggestion)

 - Jonas

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEn+Ppw2aRpp/1PMaELHwxRsGgASEFAl8S0GcACgkQLHwxRsGg
ASECDg/9GUwHzrOSDjmwRSbyIbCaY6/KkOdw2uab2P4xYizt7/Tc+scymHrWCtX5
sz20M1jXfVD/R/m9luLC47TX+2mAVgLcrirGNT/HLyPxgCa1DyV6eD+TeEeVNvuZ
/yevyUe846uuqAnlX4LGNrIhWw4lyPndSBgbm9WhxnG6qOWcXT+z3W1/GZs0K+oL
cbURFPm/yv8RPXfdE0jWNWz9poOXfaAg9a6awFOReVgnmdroGtUvef/Zo72Ll7hV
9xzBaOZ/44BNOV9rLGay3JNSTmr6rGqeXI1M/Oc7zX95MFi8MVkSVlQakbJoxMYj
VMwwfsbYM2cH4kdUkZ3ATwERESCsw/CB0gzfePgsyVFqJD0lfUvngXEqD0UUsPXR
5R0Jt3i1us897OdqZKCprO3bZoTOLbVvpQZT7iY969z4sjhXo4Oakv71czbhLCQh
5tr2aNpmb61IyL2qwRQ+bfW8+9cmsuXj2/8m3qe3lhIRzALNhGsWq1eg990MaFqT
HGk7R3/ifxHvxBVlP7uKcvOhmNYSPpVbZ9osmyCkfLlhLCLgHd9GiyA95zuIqpwc
bnyPYWxDYMIka2RWXsi8Q6kQ6w6+UmjF8MIHx5/IFw1SEjbuG8/hcZwNcn3TnBgG
G8oproM3nanbzqpiJXOF0DAAgIhBr2p2icPzwVBnbrjduHVUTEU=
=7uSr
-----END PGP SIGNATURE-----


Reply to: