Skip to content

Commit

Permalink
update: project struct change
Browse files Browse the repository at this point in the history
  • Loading branch information
若尘(樱の泪) committed Feb 6, 2019
1 parent f17233c commit cdeb7e9
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 248 deletions.
15 changes: 10 additions & 5 deletions cmd/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"os"
"os/signal"
"runtime"
"syscall"
"time"

"github.com/rc452860/vnet/common/config"
Expand All @@ -33,10 +32,16 @@ func main() {
BareStarted()
}

c := make(chan os.Signal)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
<-c
cancle()
c := make(chan os.Signal, 1)
signal.Notify(c)
for {
data := <-c
log.Error("recive signal: %s", data.String())
if data == os.Interrupt {
cancle()
return
}
}
}

func BareStarted() {
Expand Down
44 changes: 12 additions & 32 deletions cmd/test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,20 @@ package main

import (
"fmt"

"github.com/miekg/dns"
"os"
"os/signal"
"syscall"
)

func main() {
c := new(dns.Client)
// c.DialTimeout = time.Millisecond * 5000
// c.ReadTimeout = time.Millisecond * 5000
// c.WriteTimeout = time.Millisecond * 5000
m := new(dns.Msg)
m.SetQuestion(dns.Fqdn("baidu.com"), dns.TypeAAAA)
r, _, err := c.Exchange(m, "[2001:4860:4860::8844]:53")
if err != nil {
fmt.Print(err)
c := make(chan os.Signal)
signal.Notify(c, os.Interrupt, syscall.SIGTERM)
for {
data := <-c
fmt.Println(data.String())
if data == os.Interrupt {
return
}
}
fmt.Println(r.Answer)
// r, _, err := c.Exchange(m, "114.114.114.114:53")
// if err != nil {
// fmt.Print("a" + err.Error())
// }
// fmt.Println(r.Answer)
// var l sync.Mutex
// c := sync.NewCond(&l)
// f := func() {
// c.L.Lock()
// defer c.L.Unlock()
// c.Wait()
// fmt.Println("aaa")
// }
// go f()
// go f()
// time.Sleep(3 * time.Second)
// c.L.Lock()
// c.Broadcast()
// c.L.Unlock()
// time.Sleep(3 * time.Second)

}
3 changes: 1 addition & 2 deletions db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import (

"github.com/rc452860/vnet/utils/addr"

"github.com/rc452860/vnet/proxy"
"github.com/rc452860/vnet/record"

"github.com/AlecAivazis/survey"
Expand Down Expand Up @@ -365,7 +364,7 @@ func formatLoad() string {
// DBTrafficMonitor is should using goroutine start
func DBTrafficMonitor(ctx context.Context) {
traffic := make(chan record.Traffic, 32)
proxy.RegisterTrafficHandle(traffic)
server.RegisterTrafficHandle(traffic)
var data record.Traffic
// count traffic
for {
Expand Down
160 changes: 0 additions & 160 deletions proxy/proxy.go

This file was deleted.

42 changes: 0 additions & 42 deletions proxy/proxy_test.go

This file was deleted.

13 changes: 6 additions & 7 deletions proxy/server/shadowsocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import (
"github.com/rc452860/vnet/common/pool"
"github.com/rc452860/vnet/network/ciphers"
"github.com/rc452860/vnet/network/conn"
"github.com/rc452860/vnet/proxy"
"github.com/rc452860/vnet/record"
"github.com/rc452860/vnet/socks"
"golang.org/x/time/rate"
Expand All @@ -44,11 +43,11 @@ func init() {
// ShadowsocksProxy is respect shadowsocks proxy server
// it have Start and Stop method to control proxy
type ShadowsocksProxy struct {
*proxy.ProxyService `json:"-,omitempty"`
Host string `json:"host,omitempty"`
Port int `json:"port,omitempty"`
Method string `json:"method,omitempty"`
Password string `json:"password,omitempty"`
*ProxyService `json:"-,omitempty"`
Host string `json:"host,omitempty"`
Port int `json:"port,omitempty"`
Method string `json:"method,omitempty"`
Password string `json:"password,omitempty"`
ShadowsocksArgs
ReadLimiter *rate.Limiter `json:"read_limit,omitempty"`
WriteLimiter *rate.Limiter `json:"write_limit,omitempty"`
Expand All @@ -65,7 +64,7 @@ type ShadowsocksArgs struct {
// NewShadowsocks is new ShadowsocksProxy object
func NewShadowsocks(host string, method string, password string, port int, ssarg ShadowsocksArgs) (*ShadowsocksProxy, error) {
ss := &ShadowsocksProxy{
ProxyService: proxy.NewProxyService(),
ProxyService: NewProxyService(),
Host: host,
Method: method,
Password: password,
Expand Down

0 comments on commit cdeb7e9

Please sign in to comment.