@@ -10,6 +10,7 @@ import (
10
10
"net/url"
11
11
"os"
12
12
"path"
13
+ "strings"
13
14
"time"
14
15
15
16
"github.com/Notifiarr/notifiarr/pkg/mnd"
@@ -65,6 +66,7 @@ func (c *Client) startTunnel(ctx context.Context) {
65
66
// If clientinfo is nil, then we probably have a bad API key.
66
67
ci := clientinfo .Get ()
67
68
if ci == nil {
69
+ c .Errorf ("Skipping tunnel creation because there is no client info." )
68
70
return
69
71
}
70
72
@@ -86,7 +88,7 @@ func (c *Client) startTunnel(ctx context.Context) {
86
88
poolmax ++
87
89
}
88
90
89
- if poolmax > maxPoolSize {
91
+ if poolmax > maxPoolSize || ci . IsSub () {
90
92
poolmax = maxPoolSize
91
93
} else if poolmax < maxPoolMin {
92
94
poolmax = maxPoolMin
@@ -112,8 +114,11 @@ func (c *Client) startTunnel(ctx context.Context) {
112
114
Backoff : 600 * time .Millisecond + time .Duration (c .triggers .Timers .Rand ().Intn (600 ))* time .Millisecond ,
113
115
SecretKey : c .Config .APIKey ,
114
116
Handler : remWs .Wrap (c .prefixURLbase (c .Config .Router ), c .Logger .HTTPLog .Writer ()).ServeHTTP ,
115
- Logger : & tunnelLogger {Logger : c .Logger },
117
+ Logger : & tunnelLogger {Logger : c .Logger , sendSiteErrors : ci . User . DevAllowed },
116
118
})
119
+ c .Printf ("Tunneling to %q with %d connections; cleaner:%s, backoff:%s, url: %s, hash: %s" ,
120
+ strings .Join (c .tunnel .Targets , ", " ), c .tunnel .PoolMaxSize , c .tunnel .CleanInterval ,
121
+ c .tunnel .Backoff , ci .User .TunnelURL , c .tunnel .GetID ())
117
122
c .tunnel .Start (ctx )
118
123
}
119
124
@@ -237,6 +242,8 @@ func (n *netConnWrapper) Write(b []byte) (int, error) {
237
242
// tunnelLogger lets us tune the logs from the mulery tunnel.
238
243
type tunnelLogger struct {
239
244
mnd.Logger
245
+ // sendSiteErrors true sends tunnel errors to website as notifications.
246
+ sendSiteErrors bool
240
247
}
241
248
242
249
// Debugf prints a message with DEBUG prefixed.
@@ -246,7 +253,12 @@ func (l *tunnelLogger) Debugf(format string, v ...interface{}) {
246
253
247
254
// Errorf prints a message with ERROR prefixed.
248
255
func (l * tunnelLogger ) Errorf (format string , v ... interface {}) {
249
- l .Logger .ErrorfNoShare (format , v ... ) // this is why we dont just pass the interface in as-is.
256
+ // this is why we dont just pass the interface in as-is.
257
+ if l .sendSiteErrors {
258
+ l .Logger .Errorf (format , v ... )
259
+ } else {
260
+ l .Logger .ErrorfNoShare (format , v ... )
261
+ }
250
262
}
251
263
252
264
// Printf prints a message with INFO prefixed.
0 commit comments