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

MPX-24 - Support proxy CoAP #43

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
Open

Conversation

SammyOina
Copy link
Contributor

@SammyOina SammyOina commented Oct 3, 2023

Signed-off-by: SammyOina [email protected]

What does this do?

  • New Feature: Added support for CoAP proxying with TLS and DTLS in cmd/main.go and pkg/coap/coap.go. This allows users to securely send CoAP messages and proxy them to a target server.
  • Refactor: Updated the LoadTLSCfg function in pkg/tls/tls.go to use os.ReadFile instead of the deprecated ioutil.ReadFile.

Which issue(s) does this PR fix/relate to?

Resolves #24.

List any changes that modify/break current functionality

Have you included tests for your changes?

Did you document any new/modified functionality?

Notes

@SammyOina SammyOina changed the title proxy coap UV-267 - Support proxy coap Oct 3, 2023
Signed-off-by: SammyOina <[email protected]>
The commit refactors the CoAP configuration variables in the main.go file.
It introduces new environment variables and updates the default values for
the CoAP host, port, target host, target port, and DTLS settings. The
refactoring aims to improve the clarity and consistency of the codebase.

Signed-off-by: SammyOina <[email protected]>
The commit fixes an error in the loadConfig function where an invalid value was being passed for the envCoAPDTLS environment variable. The error message was also updated to reflect the correct variable name.

This commit also adds a return statement in the handler function of the coap package to handle an error when retrieving the path from the request options. Additionally, it initializes the logger and address fields in the NewProxy function of the coap package.

The changes ensure that the loadConfig function handles the correct environment variable and that the handler function in the coap package returns when an error occurs. The NewProxy function in the coap package now correctly initializes the logger and address fields.

Signed-off-by: SammyOina <[email protected]>
The CoAP proxy handler had a bug where the path was not correctly extracted from the request options. This caused errors when trying to send the request to the target connection. This commit fixes the bug by correctly extracting the path and using it to make the request to the target connection.

This commit also adds a new method, `observeUpstream`, to handle CoAP observe requests. This method extracts the path from the request options and sets up a callback function to handle incoming observe notifications from the target connection.

The bug fix and new method improve the reliability and functionality of the CoAP proxy handler.

Signed-off-by: SammyOina <[email protected]>
The CoapConfig struct in main.go has been refactored to improve code organization and readability. The struct now includes separate fields for host, port, DTLS, targetHost, and targetPort. This change allows for better configuration of CoAP settings. The code has been updated to reflect these changes.

Signed-off-by: SammyOina <[email protected]>
Signed-off-by: SammyOina <[email protected]>
@SammyOina SammyOina requested a review from dborovcanin October 22, 2023 20:30
@SammyOina SammyOina marked this pull request as draft October 23, 2023 14:38
- Fix import of context package
- Fix variable naming in Proxy struct

Signed-off-by: SammyOina <[email protected]>
@dborovcanin dborovcanin marked this pull request as ready for review October 24, 2023 12:58
pkg/coap/coap.go Show resolved Hide resolved
pkg/coap/coap.go Outdated Show resolved Hide resolved
pkg/coap/coap.go Show resolved Hide resolved
pkg/coap/coap.go Show resolved Hide resolved
@SammyOina SammyOina requested a review from dborovcanin October 25, 2023 16:52
@dborovcanin dborovcanin changed the title UV-267 - Support proxy coap MPX-24 - Support proxy CoAP Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

Add support for CoAP and DTLS
2 participants