-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
193 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
//go:build !wasip1 | ||
|
||
package main | ||
|
||
import ( | ||
"context" | ||
"os" | ||
"os/signal" | ||
) | ||
|
||
func SigIntHandler(ctx context.Context, cancel func()) { | ||
// translate ^C (Interrput) in ctx.Done() | ||
c := make(chan os.Signal, 1) | ||
signal.Notify(c, os.Interrupt) // NOT WITH WASM! | ||
select { | ||
case <-c: | ||
cancel() | ||
case <-ctx.Done(): | ||
} | ||
|
||
signal.Stop(c) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
//go:build wasip1 | ||
|
||
package main | ||
|
||
import ( | ||
"context" | ||
) | ||
|
||
func SigIntHandler(ctx context.Context, cancel func()) { | ||
// does currently not work with WASM and makes the program hang. | ||
// signal.Notify(c, os.Interrupt) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,9 @@ | ||
//go:build !wasip1 | ||
|
||
package rabtap | ||
|
||
import ( | ||
"crypto/tls" | ||
"net/url" | ||
"time" | ||
|
||
amqp "github.com/rabbitmq/amqp091-go" | ||
) | ||
|
||
const ( | ||
defaultHeartbeat = 10 * time.Second | ||
defaultLocale = "en_US" | ||
"net" | ||
) | ||
|
||
// DialTLS is a Wrapper for amqp.DialTLS that supports EXTERNAL auth for mtls | ||
// can be removed when https://github.com/streadway/amqp/pull/121 gets some day | ||
// merged. | ||
func DialTLS(uri string, tlsConfig *tls.Config) (*amqp.Connection, error) { | ||
|
||
u, err := url.Parse(uri) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// if client certificates are specified and no explicit credentials in the | ||
// amqp connect url are given, then request EXTERNAL auth. | ||
var sasl []amqp.Authentication | ||
if tlsConfig.Certificates != nil && u.User == nil { | ||
sasl = []amqp.Authentication{&amqp.ExternalAuth{}} | ||
} | ||
|
||
return amqp.DialConfig(uri, amqp.Config{ | ||
Heartbeat: defaultHeartbeat, | ||
TLSClientConfig: tlsConfig, | ||
Locale: defaultLocale, | ||
SASL: sasl, | ||
}) | ||
} | ||
var Dialer = net.Dial |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package rabtap | ||
|
||
import "net" | ||
|
||
type DialFunc func(network, addr string) (net.Conn, error) |
Oops, something went wrong.