mirror of
https://github.com/yusing/godoxy.git
synced 2025-06-09 04:52:35 +02:00
fixed typos and formatting, fixed loading page not being shown (idlewaker)
This commit is contained in:
parent
d1c9e18c97
commit
1797896fa6
6 changed files with 23 additions and 29 deletions
|
@ -1,8 +1,9 @@
|
|||
package autocert
|
||||
|
||||
import (
|
||||
"github.com/go-acme/lego/v4/registration"
|
||||
"crypto"
|
||||
|
||||
"github.com/go-acme/lego/v4/registration"
|
||||
)
|
||||
|
||||
type User struct {
|
||||
|
|
|
@ -64,7 +64,7 @@ func (w *Waker) wake(next http.HandlerFunc, rw http.ResponseWriter, r *http.Requ
|
|||
defer cancel()
|
||||
|
||||
accept := gphttp.GetAccept(r.Header)
|
||||
acceptHTML := r.Method == http.MethodGet && accept.AcceptHTML()
|
||||
acceptHTML := (r.Method == http.MethodGet && accept.AcceptHTML() || r.RequestURI == "/" && accept.IsEmpty())
|
||||
|
||||
isCheckRedirect := r.Header.Get(headerCheckRedirect) != ""
|
||||
if !isCheckRedirect && acceptHTML {
|
||||
|
|
|
@ -36,7 +36,7 @@ func (route *TCPRoute) Setup() error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
//! this read the allocated port from orginal ':0'
|
||||
//! this read the allocated port from original ':0'
|
||||
route.Port.ListeningPort = T.Port(in.Addr().(*net.TCPAddr).Port)
|
||||
route.listener = in
|
||||
return nil
|
||||
|
|
|
@ -51,7 +51,7 @@ func (route *UDPRoute) Setup() error {
|
|||
return err
|
||||
}
|
||||
|
||||
//! this read the allocated listeningPort from orginal ':0'
|
||||
//! this read the allocated listeningPort from original ':0'
|
||||
route.Port.ListeningPort = T.Port(source.LocalAddr().(*net.UDPAddr).Port)
|
||||
|
||||
route.listeningConn = source
|
||||
|
|
|
@ -6,6 +6,7 @@ import (
|
|||
"errors"
|
||||
"io"
|
||||
"os"
|
||||
"sync"
|
||||
"syscall"
|
||||
|
||||
E "github.com/yusing/go-proxy/internal/error"
|
||||
|
@ -28,10 +29,8 @@ type (
|
|||
}
|
||||
|
||||
Pipe struct {
|
||||
r ContextReader
|
||||
w ContextWriter
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc
|
||||
r ContextReader
|
||||
w ContextWriter
|
||||
}
|
||||
|
||||
BidirectionalPipe struct {
|
||||
|
@ -59,12 +58,9 @@ func (w *ContextWriter) Write(p []byte) (int, error) {
|
|||
}
|
||||
|
||||
func NewPipe(ctx context.Context, r io.ReadCloser, w io.WriteCloser) *Pipe {
|
||||
_, cancel := context.WithCancel(ctx)
|
||||
return &Pipe{
|
||||
r: ContextReader{ctx: ctx, Reader: r},
|
||||
w: ContextWriter{ctx: ctx, Writer: w},
|
||||
ctx: ctx,
|
||||
cancel: cancel,
|
||||
r: ContextReader{ctx: ctx, Reader: r},
|
||||
w: ContextWriter{ctx: ctx, Writer: w},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -87,22 +83,20 @@ func NewBidirectionalPipe(ctx context.Context, rw1 io.ReadWriteCloser, rw2 io.Re
|
|||
}
|
||||
}
|
||||
|
||||
func NewBidirectionalPipeIntermediate(ctx context.Context, listener io.ReadCloser, client io.ReadWriteCloser, target io.ReadWriteCloser) *BidirectionalPipe {
|
||||
return &BidirectionalPipe{
|
||||
pSrcDst: NewPipe(ctx, listener, client),
|
||||
pDstSrc: NewPipe(ctx, client, target),
|
||||
}
|
||||
}
|
||||
|
||||
func (p BidirectionalPipe) Start() error {
|
||||
errCh := make(chan error, 2)
|
||||
var wg sync.WaitGroup
|
||||
wg.Add(2)
|
||||
b := E.NewBuilder("bidirectional pipe error")
|
||||
go func() {
|
||||
errCh <- p.pSrcDst.Start()
|
||||
b.AddE(p.pSrcDst.Start())
|
||||
wg.Done()
|
||||
}()
|
||||
go func() {
|
||||
errCh <- p.pDstSrc.Start()
|
||||
b.AddE(p.pDstSrc.Start())
|
||||
wg.Done()
|
||||
}()
|
||||
return E.JoinE("bidirectional pipe error", <-errCh, <-errCh).Error()
|
||||
wg.Wait()
|
||||
return b.Build().Error()
|
||||
}
|
||||
|
||||
func Copy(dst *ContextWriter, src *ContextReader) error {
|
||||
|
|
|
@ -149,9 +149,8 @@ func Deserialize(src SerializedObject, dst any) E.NestedError {
|
|||
|
||||
if dstV.Kind() == reflect.Struct {
|
||||
mapping := make(map[string]reflect.Value)
|
||||
for i := 0; i < dstV.NumField(); i++ {
|
||||
field := dstT.Field(i)
|
||||
mapping[ToLowerNoSnake(field.Name)] = dstV.Field(i)
|
||||
for _, field := range reflect.VisibleFields(dstT) {
|
||||
mapping[ToLowerNoSnake(field.Name)] = dstV.FieldByName(field.Name)
|
||||
}
|
||||
for k, v := range src {
|
||||
if field, ok := mapping[ToLowerNoSnake(k)]; ok {
|
||||
|
@ -322,7 +321,7 @@ func ConvertString(src string, dst reflect.Value) (convertible bool, convErr E.N
|
|||
var tmp any
|
||||
switch dst.Kind() {
|
||||
case reflect.Slice:
|
||||
// one liner is comma seperated list
|
||||
// one liner is comma separated list
|
||||
if len(lines) == 0 {
|
||||
dst.Set(reflect.ValueOf(CommaSeperatedList(src)))
|
||||
return
|
||||
|
|
Loading…
Add table
Reference in a new issue