mirror of
https://github.com/dstotijn/hetty
synced 2024-11-10 06:04:19 +00:00
Initial commit
This commit is contained in:
commit
26ec9f72e5
3 changed files with 61 additions and 0 deletions
5
go.mod
Normal file
5
go.mod
Normal file
|
@ -0,0 +1,5 @@
|
|||
module github.com/dstotijn/gurp
|
||||
|
||||
go 1.13
|
||||
|
||||
require github.com/google/martian v2.1.0+incompatible
|
2
go.sum
Normal file
2
go.sum
Normal file
|
@ -0,0 +1,2 @@
|
|||
github.com/google/martian v2.1.0+incompatible h1:/CP5g8u/VJHijgedC/Legn3BAbAaWPgecwXBIDzw5no=
|
||||
github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs=
|
54
main.go
Normal file
54
main.go
Normal file
|
@ -0,0 +1,54 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"crypto/x509"
|
||||
"log"
|
||||
"net"
|
||||
"os"
|
||||
"os/signal"
|
||||
"time"
|
||||
|
||||
"github.com/google/martian"
|
||||
"github.com/google/martian/mitm"
|
||||
)
|
||||
|
||||
func main() {
|
||||
p := martian.NewProxy()
|
||||
defer p.Close()
|
||||
|
||||
tlsc, err := tls.LoadX509KeyPair("/Users/dstotijn/.ssh/gurp_cert.pem", "/Users/dstotijn/.ssh/gurp_key.pem")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
priv := tlsc.PrivateKey
|
||||
|
||||
x509c, err := x509.ParseCertificate(tlsc.Certificate[0])
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
mc, err := mitm.NewConfig(x509c, priv)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
mc.SetValidity(time.Hour)
|
||||
mc.SetOrganization("Gurp, Inc.")
|
||||
|
||||
p.SetMITM(mc)
|
||||
|
||||
l, err := net.Listen("tcp", ":8080")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
go func() {
|
||||
if err := p.Serve(l); err != nil {
|
||||
log.Println(err)
|
||||
}
|
||||
}()
|
||||
|
||||
sigc := make(chan os.Signal, 1)
|
||||
signal.Notify(sigc, os.Interrupt, os.Kill)
|
||||
<-sigc
|
||||
}
|
Loading…
Reference in a new issue