mirror of
https://github.com/boringproxy/boringproxy.git
synced 2025-02-25 18:55:29 -06:00
Add error handling for cert failure
This commit is contained in:
parent
9bd415af50
commit
10f79beec6
@ -299,7 +299,12 @@ func (p *BoringProxy) handleCreateTunnel(w http.ResponseWriter, r *http.Request)
|
||||
return
|
||||
}
|
||||
|
||||
p.tunMan.SetTunnel(host, port)
|
||||
err = p.tunMan.SetTunnel(host, port)
|
||||
if err != nil {
|
||||
w.WriteHeader(400)
|
||||
io.WriteString(w, "Failed to get cert. Ensure your domain is valid")
|
||||
return
|
||||
}
|
||||
|
||||
http.Redirect(w, r, "/", 303)
|
||||
}
|
||||
|
@ -53,11 +53,11 @@ func NewTunnelManager(certConfig *certmagic.Config) *TunnelManager {
|
||||
return &TunnelManager{tunnels, mutex, certConfig}
|
||||
}
|
||||
|
||||
func (m *TunnelManager) SetTunnel(host string, port int) {
|
||||
func (m *TunnelManager) SetTunnel(host string, port int) error {
|
||||
err := m.certConfig.ManageSync([]string{host})
|
||||
if err != nil {
|
||||
log.Println("CertMagic error")
|
||||
log.Println(err)
|
||||
return errors.New("Failed to get cert")
|
||||
}
|
||||
|
||||
tunnel := &Tunnel{port}
|
||||
@ -65,6 +65,8 @@ func (m *TunnelManager) SetTunnel(host string, port int) {
|
||||
m.tunnels[host] = tunnel
|
||||
saveJson(m.tunnels, "tunnels.json")
|
||||
m.mutex.Unlock()
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *TunnelManager) DeleteTunnel(host string) {
|
||||
|
Loading…
Reference in New Issue
Block a user