fix: added socket closing to prevent resource leak

    Detected by static analyzer that socket is not closed after use,
    which can lead to resource leak and potential vulnerabilities such as
    file descriptor exhaustion or denial of service (DoS) attacks.

    Changes:
    - Added `socket.Close()` call after finishing work with socket.
    - Ensured that socket is closed even in case of errors while writing data.

    This fix improves stability and security of code.
1 file changed
tree: d0647e264ac2015d0da367fa43b18fe0a5286258
  1. .github/
  2. _examples/
  3. introspect/
  4. prop/
  5. testdata/
  6. .cirrus.yml
  7. .golangci.yml
  8. auth.go
  9. auth_anonymous.go
  10. auth_external.go
  11. auth_sha1.go
  12. call.go
  13. conn.go
  14. conn_darwin.go
  15. conn_linux_test.go
  16. conn_other.go
  17. conn_test.go
  18. conn_unix.go
  19. conn_windows.go
  20. CONTRIBUTING.md
  21. dbus.go
  22. dbus_test.go
  23. decoder.go
  24. decoder_test.go
  25. default_handler.go
  26. doc.go
  27. encoder.go
  28. encoder_test.go
  29. escape.go
  30. escape_test.go
  31. examples_test.go
  32. exec_command_test.go
  33. export.go
  34. export_test.go
  35. go.mod
  36. go.sum
  37. homedir.go
  38. LICENSE
  39. MAINTAINERS
  40. match.go
  41. match_test.go
  42. message.go
  43. message_test.go
  44. object.go
  45. object_test.go
  46. proto_fuzz_test.go
  47. proto_test.go
  48. README.md
  49. SECURITY.md
  50. sequence.go
  51. sequence_test.go
  52. sequential_handler.go
  53. sequential_handler_test.go
  54. server_interfaces.go
  55. server_interfaces_test.go
  56. sig.go
  57. sig_test.go
  58. store_test.go
  59. transport_darwin.go
  60. transport_generic.go
  61. transport_nonce_tcp.go
  62. transport_nonce_tcp_test.go
  63. transport_tcp.go
  64. transport_tcp_test.go
  65. transport_unix.go
  66. transport_unix_test.go
  67. transport_unixcred_dragonfly.go
  68. transport_unixcred_freebsd.go
  69. transport_unixcred_linux.go
  70. transport_unixcred_netbsd.go
  71. transport_unixcred_openbsd.go
  72. transport_zos.go
  73. variant.go
  74. variant_lexer.go
  75. variant_parser.go
  76. variant_test.go
README.md

Build Status

dbus

dbus is a simple library that implements native Go client bindings for the D-Bus message bus system.

Features

  • Complete native implementation of the D-Bus message protocol
  • Go-like API (channels for signals / asynchronous method calls, Goroutine-safe connections)
  • Subpackages that help with the introspection / property interfaces

Installation

This packages requires Go 1.20 or later. It can be installed by running the command below:

go get github.com/godbus/dbus/v5

Usage

The complete package documentation and some simple examples are available at pkg.go.dev. Also, the _examples directory gives a short overview over the basic usage.

Projects using godbus

  • fyne a cross platform GUI in Go inspired by Material Design.
  • fynedesk a full desktop environment for Linux/Unix using Fyne.
  • go-bluetooth provides a bluetooth client over bluez dbus API.
  • iwd go bindings for the internet wireless daemon “iwd”.
  • notify provides desktop notifications over dbus into a library.
  • playerbm a bookmark utility for media players.
  • rpic lightweight web app and RESTful API for managing a Raspberry Pi

Please note that the API is considered unstable for now and may change without further notice.

License

go.dbus is available under the Simplified BSD License; see LICENSE for the full text.

Nearly all of the credit for this library goes to github.com/guelfey/go.dbus.