Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .github/workflows/test-for-fork.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ jobs:

- run: go version

- name: Install coap-client
run: |
if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then
sudo apt-get update
sudo apt-get install -y libcoap3-bin
sudo ln -s /usr/bin/coap-client-notls /usr/bin/coap-client
elif [ "${{ matrix.os }}" == "macOS-latest" ]; then
brew install libcoap
fi
shell: bash

# Checks-out repository under $GITHUB_WORKSPACE
- name: Checkout
uses: actions/checkout@v5
Expand Down
18 changes: 18 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ jobs:

- run: go version

- name: Install coap-client
run: |
if [ "${{ matrix.os }}" == "ubuntu-latest" ]; then
sudo apt-get update
sudo apt-get install -y libcoap3-bin
sudo ln -s /usr/bin/coap-client-notls /usr/bin/coap-client
elif [ "${{ matrix.os }}" == "macOS-latest" ]; then
brew install libcoap
fi
shell: bash

# Checks-out repository under $GITHUB_WORKSPACE with tags and history (needed by "SonarCloud Scan" step)
- name: Full checkout
uses: actions/checkout@v5
Expand Down Expand Up @@ -118,6 +129,13 @@ jobs:

- run: go version

- name: Install coap-client
run: |
sudo apt-get update
sudo apt-get install -y libcoap3-bin
sudo ln -s /usr/bin/coap-client-notls /usr/bin/coap-client
shell: bash

- name: Checkout
uses: actions/checkout@v5

Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ client
!client/
vendor/
v3/

/.idea/
# Test binary, build with `go test -c`
*.test

Expand Down
16 changes: 8 additions & 8 deletions dtls/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,21 @@ func createDTLSConfig() (serverConfig *piondtls.Config, clientConfig *piondtls.C
// root cert
ca, rootBytes, _, caPriv, err := pki.GenerateCA()
if err != nil {
return
return serverConfig, clientConfig, clientSerial, err
}
// server cert
certBytes, keyBytes, err := pki.GenerateCertificate(ca, caPriv, "server@test.com")
if err != nil {
return
return serverConfig, clientConfig, clientSerial, err
}
certificate, err := pki.LoadKeyAndCertificate(keyBytes, certBytes)
if err != nil {
return
return serverConfig, clientConfig, clientSerial, err
}
// cert pool
certPool, err := pki.LoadCertPool(rootBytes)
if err != nil {
return
return serverConfig, clientConfig, clientSerial, err
}

serverConfig = &piondtls.Config{
Expand All @@ -116,15 +116,15 @@ func createDTLSConfig() (serverConfig *piondtls.Config, clientConfig *piondtls.C
// client cert
certBytes, keyBytes, err = pki.GenerateCertificate(ca, caPriv, "client@test.com")
if err != nil {
return
return serverConfig, clientConfig, clientSerial, err
}
certificate, err = pki.LoadKeyAndCertificate(keyBytes, certBytes)
if err != nil {
return
return serverConfig, clientConfig, clientSerial, err
}
clientInfo, err := x509.ParseCertificate(certificate.Certificate[0])
if err != nil {
return
return serverConfig, clientConfig, clientSerial, err
}
clientSerial = clientInfo.SerialNumber

Expand All @@ -135,7 +135,7 @@ func createDTLSConfig() (serverConfig *piondtls.Config, clientConfig *piondtls.C
InsecureSkipVerify: true,
}

return
return serverConfig, clientConfig, clientSerial, err
}

func TestServerSetContextValueWithPKI(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

func main() {
co, err := udp.Dial("localhost:5688")
co, err := udp.Dial("localhost:5685")
Comment thread
coderabbitai[bot] marked this conversation as resolved.
if err != nil {
log.Fatalf("Error dialing: %v", err)
}
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,5 @@ func main() {
r.Handle("/a", mux.HandlerFunc(handleA))
r.Handle("/b", mux.HandlerFunc(handleB))

log.Fatal(coap.ListenAndServe("udp", ":5688", r))
log.Fatal(coap.ListenAndServe("udp", ":5685", r))
}
4 changes: 2 additions & 2 deletions mux/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ func (r *Router) Match(path string, routeParams *RouteParams) (matchedRoute *Rou
r.m.RUnlock()

if matchedRoute == nil {
return
return matchedRoute, matchedPattern
}

routeParams.Path = path
Expand All @@ -133,7 +133,7 @@ func (r *Router) Match(path string, routeParams *RouteParams) (matchedRoute *Rou
routeParams.PathTemplate = matchedPattern
matchedRoute.regexMatcher.extractRouteParams(path, routeParams)

return
return matchedRoute, matchedPattern
}

// Handle adds a handler to the Router for pattern.
Expand Down
Loading
Loading