Projects STRLCPY prox5 Commits 163c85a8
🤬
  • ■ ■ ■ ■ ■ ■
    defs.go
    skipped 2 lines
    3 3  import (
    4 4   "context"
    5 5   "fmt"
     6 + "net/http"
    6 7   "sync"
    7 8   "sync/atomic"
    8 9   "time"
    skipped 39 lines
    48 49   mu *sync.RWMutex
    49 50   pool *ants.Pool
    50 51   swampopt *swampOptions
     52 + httpClient *http.Client
    51 53   runningdaemons int32
    52 54   conductor chan bool
    53 55  }
    skipped 234 lines
  • ■ ■ ■ ■ ■
    example/main.go
    skipped 1 lines
    2 2   
    3 3  import (
    4 4   "fmt"
     5 + "io"
    5 6   "os"
     7 + "os/signal"
    6 8   "strconv"
     9 + "syscall"
    7 10   "time"
    8 11   
    9 12   "git.tcp.direct/kayos/prox5"
    skipped 115 lines
    125 128   case "q":
    126 129   done = true
    127 130   break
     131 + case "i":
     132 + go func() {
     133 + res, getErr := swamp.GetHTTPClient().Get("https://wtfismyip.com/text")
     134 + if getErr != nil {
     135 + println(getErr.Error())
     136 + return
     137 + }
     138 + io.Copy(os.Stdout, res.Body)
     139 + }()
    128 140   default:
    129 141   //
    130 142   }
    skipped 1 lines
    132 144   break
    133 145   }
    134 146   }
    135  - 
     147 + _ = t.Close()
    136 148   quit <- true
    137 149   return
    138 150  }
    139 151   
     152 +func sigWatch() {
     153 + c := make(chan os.Signal, 5)
     154 + signal.Notify(c, os.Interrupt, syscall.SIGTERM)
     155 + for {
     156 + select {
     157 + case <-c:
     158 + if t != nil {
     159 + _ = t.Close()
     160 + }
     161 + os.Exit(9)
     162 + }
     163 + }
     164 +}
     165 + 
    140 166  func main() {
    141 167   go watchKeyPresses()
    142  - 
    143  - defer func(t *tty.TTY) {
    144  - _ = t.Close()
    145  - }(t)
     168 + go sigWatch()
    146 169   
    147 170   go func() {
    148 171   for {
    skipped 8 lines
  • ■ ■ ■ ■ ■
    mrworldwide.go
    skipped 6 lines
    7 7   
    8 8  // GetHTTPClient retrieves a pointer to an http.Client powered by MysteryDialer.
    9 9  func (s *Swamp) GetHTTPClient() *http.Client {
    10  - return &http.Client{
     10 + if s.httpClient != nil {
     11 + return s.httpClient
     12 + }
     13 + s.httpClient = &http.Client{
    11 14   Transport: &http.Transport{
    12 15   DialContext: s.DialContext,
    13 16   DisableKeepAlives: true,
    skipped 2 lines
    16 19   },
    17 20   Timeout: s.GetServerTimeout(),
    18 21   }
     22 + return s.httpClient
    19 23  }
    20 24   
    21 25  // RoundTrip is Mr. WorldWide. Obviously. See: https://pkg.go.dev/net/http#RoundTripper
    skipped 4 lines
Please wait...
Page is in error, reload to recover