Skip to content

Commit

Permalink
Fix cert and key reading for broflake on lantern cloud (#626)
Browse files Browse the repository at this point in the history
* Fix cert and key reading for broflake on lantern cloud
  • Loading branch information
AGMETEOR authored Sep 6, 2024
1 parent 28580ab commit 99f7b62
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
1 change: 0 additions & 1 deletion broflake/broflake.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ import (
)

func Wrap(ll net.Listener, certPEM string, keyPEM string) (net.Listener, error) {
// TODO: update the Broflake library to accept cert and key as PEM encoded strings
return egress.NewListener(context.Background(), ll, certPEM, keyPEM)
}
4 changes: 1 addition & 3 deletions http-proxy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ func main() {
HTTPAddr: *addr,
HTTPMultiplexAddr: *multiplexAddr,
CertFile: *certfile,
KeyFile: *keyfile,
CfgSvrAuthToken: *cfgSvrAuthToken,
ConnectOKWaitsForUpstream: *connectOKWaitsForUpstream,
EnableMultipath: *enableMultipath,
Expand All @@ -393,7 +394,6 @@ func main() {
ExternalIP: *externalIP,
HTTPS: *https,
IdleTimeout: time.Duration(*idleClose) * time.Second,
KeyFile: *keyfile,
SessionTicketKeys: *sessionTicketKeys,
SessionTicketKeyFile: *sessionTicketKeyFile,
FirstSessionTicketKey: *firstSessionTicketKey,
Expand Down Expand Up @@ -470,8 +470,6 @@ func main() {
PsmuxAggressivePadding: *psmuxAggressivePadding,
PsmuxAggressivePaddingRatio: *psmuxAggressivePaddingRatio,
BroflakeAddr: *broflakeAddr,
BroflakeCert: os.Getenv("BROFLAKE_CERT"),
BroflakeKey: os.Getenv("BROFLAKE_KEY"),
AlgenevaAddr: *algenevaAddr,
WaterAddr: *waterAddr,
WaterWASM: *waterWASM,
Expand Down
13 changes: 12 additions & 1 deletion http_proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,18 @@ func (p *Proxy) listenBroflake(baseListen func(string) (net.Listener, error)) li
if err != nil {
return nil, err
}
wrapped, wrapErr := broflake.Wrap(l, p.BroflakeCert, p.BroflakeKey)

certPEM, err := os.ReadFile(p.CertFile)
if err != nil {
log.Fatalf("Unable to read certificate file: %v", err)
}

keyPEM, err := os.ReadFile(p.KeyFile)
if err != nil {
log.Fatalf("Unable to read key file: %v", err)
}

wrapped, wrapErr := broflake.Wrap(l, string(certPEM), string(keyPEM))
if wrapErr != nil {
log.Fatalf("Unable to initialize broflake with tcp: %v", wrapErr)
}
Expand Down

0 comments on commit 99f7b62

Please sign in to comment.