Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
b43178746e | ||
![]() |
72dc2b1d74 |
68
conn.go
Normal file
68
conn.go
Normal file
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Henry
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
*/
|
||||
|
||||
package goSam
|
||||
|
||||
import (
|
||||
"log"
|
||||
"net"
|
||||
"time"
|
||||
)
|
||||
|
||||
type Conn struct {
|
||||
RWC
|
||||
conn net.Conn
|
||||
}
|
||||
|
||||
func WrapConn(c net.Conn) *Conn {
|
||||
wrap := Conn{
|
||||
conn: c,
|
||||
}
|
||||
wrap.Reader = NewReadLogger("<", c)
|
||||
wrap.Writer = NewWriteLogger(">", c)
|
||||
wrap.RWC.c = c
|
||||
return &wrap
|
||||
}
|
||||
|
||||
func (c *Conn) LocalAddr() net.Addr {
|
||||
return c.conn.LocalAddr()
|
||||
}
|
||||
|
||||
func (c *Conn) RemoteAddr() net.Addr {
|
||||
return c.conn.RemoteAddr()
|
||||
}
|
||||
|
||||
func (c *Conn) SetDeadline(t time.Time) error {
|
||||
log.Println("WARNING: SetDeadline() not sure this works")
|
||||
return c.conn.SetDeadline(t)
|
||||
}
|
||||
|
||||
func (c *Conn) SetReadDeadline(t time.Time) error {
|
||||
log.Println("WARNING: SetReadDeadline() not sure this works")
|
||||
return c.conn.SetReadDeadline(t)
|
||||
}
|
||||
func (c *Conn) SetWriteDeadline(t time.Time) error {
|
||||
log.Println("WARNING: SetWriteDeadline() not sure this works")
|
||||
return c.conn.SetWriteDeadline(t)
|
||||
}
|
3
debian/changelog
vendored
3
debian/changelog
vendored
@@ -1,8 +1,9 @@
|
||||
golang-github-eyedeekay-gosam (0.3.2.1) bionic; urgency=medium
|
||||
|
||||
* Get rid of the debug directory, just move it into the source
|
||||
* Get rid of the old example, just use the one in the README
|
||||
|
||||
-- idk <hankhill19580@gmail.com> Fri, 18 May 2019 18:12:21 -0500
|
||||
-- idk <hankhill19580@gmail.com> Sat, 08 Dec 2019 19:11:41 -0500
|
||||
|
||||
golang-github-eyedeekay-gosam (0.3.2.0) bionic; urgency=medium
|
||||
|
||||
|
@@ -1,53 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"os"
|
||||
|
||||
"github.com/eyedeekay/goSam"
|
||||
)
|
||||
|
||||
func main() {
|
||||
//In order to enable debugging, pass the SetDebug(true) option.
|
||||
//sam, err := goSam.NewClientFromOptions(SetDebug(true))
|
||||
|
||||
// create a default sam client
|
||||
sam, err := goSam.NewDefaultClient()
|
||||
checkErr(err)
|
||||
|
||||
log.Println("Client Created")
|
||||
|
||||
// create a transport that uses SAM to dial TCP Connections
|
||||
tr := &http.Transport{
|
||||
Dial: sam.Dial,
|
||||
}
|
||||
|
||||
// create a client using this transport
|
||||
client := &http.Client{Transport: tr}
|
||||
|
||||
// send a get request
|
||||
resp, err := client.Get("http://stats.i2p/")
|
||||
checkErr(err)
|
||||
defer resp.Body.Close()
|
||||
|
||||
log.Printf("Get returned %+v\n", resp)
|
||||
|
||||
// create a file for the response
|
||||
file, err := os.Create("stats.html")
|
||||
checkErr(err)
|
||||
defer file.Close()
|
||||
|
||||
// copy the response to the file
|
||||
_, err = io.Copy(file, resp.Body)
|
||||
checkErr(err)
|
||||
|
||||
log.Println("Done.")
|
||||
}
|
||||
|
||||
func checkErr(err error) {
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
4
go.mod
4
go.mod
@@ -4,8 +4,8 @@ require github.com/eyedeekay/sam3 v0.32.2
|
||||
|
||||
//replace github.com/eyedeekay/gosam v0.1.1-0.20190814195658-27e786578944 => github.com/eyedeekay/goSam ./
|
||||
|
||||
replace github.com/eyedeekay/gosam v0.1.1-0.20190814195658-27e786578944 => ./
|
||||
replace github.com/eyedeekay/gosam v0.32.1 => ./
|
||||
|
||||
replace github.com/eyedeekay/goSam v0.1.0 => ./
|
||||
replace github.com/eyedeekay/goSam v0.32.1 => ./
|
||||
|
||||
go 1.13
|
||||
|
Reference in New Issue
Block a user