]> 127.0.0.1 Git - forward/.git/commitdiff
1
authorqydysky <qydysky@foxmail.com>
Sun, 14 Apr 2024 15:10:18 +0000 (15:10 +0000)
committerqydysky <qydysky@foxmail.com>
Sun, 14 Apr 2024 15:10:18 +0000 (15:10 +0000)
go.mod
go.sum
main_test.go

diff --git a/go.mod b/go.mod
index 68eb7d9ed873f2324c837fc51b2d2160606bb994..4db32fd956cef39c7560a04b29783e5bd986dd15 100644 (file)
--- a/go.mod
+++ b/go.mod
@@ -4,13 +4,14 @@ go 1.22.2
 
 require (
        github.com/dustin/go-humanize v1.0.1
-       github.com/qydysky/part v0.28.20240414033603
+       github.com/qydysky/part v0.28.20240414150808
 )
 
 require (
        github.com/andybalholm/brotli v1.1.0 // indirect
        github.com/davecgh/go-spew v1.1.1 // indirect
        github.com/go-ole/go-ole v1.3.0 // indirect
+       github.com/google/uuid v1.6.0 // indirect
        github.com/klauspost/compress v1.17.7 // indirect
        github.com/miekg/dns v1.1.58 // indirect
        github.com/pmezard/go-difflib v1.0.0 // indirect
@@ -26,3 +27,5 @@ require (
        golang.org/x/tools v0.19.0 // indirect
        gopkg.in/yaml.v3 v3.0.1 // indirect
 )
+
+// replace "github.com/qydysky/part" => "../part"
diff --git a/go.sum b/go.sum
index 5f3c3afa5c180453ddc90e2a2b0ccbc25bb66bc1..0bfe20eb45ad1b618994a7a18ff43fbc53baa565 100644 (file)
--- a/go.sum
+++ b/go.sum
@@ -15,8 +15,8 @@ github.com/miekg/dns v1.1.58 h1:ca2Hdkz+cDg/7eNF6V56jjzuZ4aCAE+DbVkILdQWG/4=
 github.com/miekg/dns v1.1.58/go.mod h1:Ypv+3b/KadlvW9vJfXOTf300O4UqaHFzFCuHz+rPkBY=
 github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
 github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
-github.com/qydysky/part v0.28.20240414033603 h1:SqjseibUCRvjKR+DgAn1vhQC+jeD7ISCjhONBsgBNTM=
-github.com/qydysky/part v0.28.20240414033603/go.mod h1:XytV5dI1Y7+qvjhsa2TMvi55RBZQQf0LCDYQ1kUCYqM=
+github.com/qydysky/part v0.28.20240414150808 h1:QGYKslNxGNrkQjIX0TW0Bp1XJGQuMMZvNnJmqQxaJQE=
+github.com/qydysky/part v0.28.20240414150808/go.mod h1:XytV5dI1Y7+qvjhsa2TMvi55RBZQQf0LCDYQ1kUCYqM=
 github.com/shirou/gopsutil v3.21.11+incompatible h1:+1+c1VGhc88SSonWP6foOcLhvnKlUeu/erjjvaPEYiI=
 github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA=
 github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
index d0368a85c6b92ea5f6af9e41f1b5bf56f4a40184..46d3678efad82c3d4fd8f881a2adf5e8d92bde31 100755 (executable)
@@ -4,13 +4,17 @@ import (
        "bufio"
        "context"
        "errors"
+       "fmt"
        "log"
        "net"
+       "net/http"
        "testing"
        "time"
 
        "github.com/qydysky/part"
        pctx "github.com/qydysky/part/ctx"
+       preqf "github.com/qydysky/part/reqf"
+       pweb "github.com/qydysky/part/web"
 )
 
 func Test(t *testing.T) {
@@ -46,6 +50,11 @@ func Test(t *testing.T) {
                        To:     "udp://127.0.0.1:20009",
                        Accept: []string{"127.0.0.1/32"},
                },
+               {
+                       Listen: "tcp://127.0.0.1:20011",
+                       To:     "tcp://127.0.0.1:20010",
+                       Accept: []string{"127.0.0.1/32"},
+               },
        })
 
        go func() {
@@ -75,8 +84,10 @@ func Test(t *testing.T) {
        }()
 
        time.Sleep(time.Second)
-       if e := tcpSer("127.0.0.1:20000", "127.0.0.1:20001"); e != nil {
-               t.Fatal(e)
+       for i := 0; i < 100; i++ {
+               if e := tcpSer("127.0.0.1:20000", "127.0.0.1:20001"); e != nil {
+                       t.Fatal(e)
+               }
        }
        if e := tcpSer("127.0.0.1:20002", "127.0.0.1:20003"); e == nil {
                t.Fatal(e)
@@ -93,6 +104,12 @@ func Test(t *testing.T) {
        if e := tcp2udpSer("127.0.0.1:20008", "127.0.0.1:20009"); e != nil {
                t.Fatal(e)
        }
+       if e := tcp2udpSer("127.0.0.1:20008", "127.0.0.1:20009"); e != nil {
+               t.Fatal(e)
+       }
+       if e := webSer("127.0.0.1:20008", "127.0.0.1:20009"); e != nil {
+               t.Fatal(e)
+       }
 }
 
 func tcpSer(lis, to string) error {
@@ -149,7 +166,7 @@ func tcpSer(lis, to string) error {
        if err != nil {
                return err
        }
-
+       conn.SetDeadline(time.Now().Add(time.Second))
        // Send a message to the server
        _, err = conn.Write([]byte("Hello TCP Server\n"))
        if err != nil {
@@ -392,3 +409,24 @@ func tcp2udpSer(lis, to string) error {
                return nil
        }
 }
+
+func webSer(lis, to string) error {
+       {
+               w := pweb.New(&http.Server{
+                       Addr: "127.0.0.1:20010",
+               })
+               defer w.Shutdown()
+
+               w.Handle(map[string]func(http.ResponseWriter, *http.Request){
+                       `/`: func(w http.ResponseWriter, r *http.Request) {
+                               w.Write([]byte("999"))
+                       },
+               })
+       }
+       r := preqf.New()
+       e := r.Reqf(preqf.Rval{
+               Url: "http://127.0.0.1:20010",
+       })
+       fmt.Println(r.Respon)
+       return e
+}