Skip to content

Commit

Permalink
Merge pull request #781 from fatedier/dev
Browse files Browse the repository at this point in the history
bump version to 0.19.1
  • Loading branch information
fatedier authored May 19, 2018
2 parents f1bea49 + e1918f6 commit da78e3f
Show file tree
Hide file tree
Showing 29 changed files with 2,402 additions and 2,187 deletions.
Binary file not shown.
Binary file removed assets/static/b02bdc1b846fd65473922f5f62832108.ttf
Binary file not shown.
2 changes: 1 addition & 1 deletion assets/static/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!DOCTYPE html> <html lang=en> <head> <meta charset=utf-8> <title>frps dashboard</title> <link rel="shortcut icon" href="favicon.ico"></head> <body> <div id=app></div> <script type="text/javascript" src="manifest.js?33af4addd27a494b40c1"></script><script type="text/javascript" src="vendor.js?c2d294f9c0a40fd7073a"></script><script type="text/javascript" src="index.js?a0da222d4e0f906bc057"></script></body> </html>
<!DOCTYPE html> <html lang=en> <head> <meta charset=utf-8> <title>frps dashboard</title> <link rel="shortcut icon" href="favicon.ico"></head> <body> <div id=app></div> <script type="text/javascript" src="manifest.js?b90a32ccfb87def61aaa"></script><script type="text/javascript" src="vendor.js?f04985ef00f520142368"></script></body> </html>
7 changes: 0 additions & 7 deletions assets/static/index.js

This file was deleted.

2 changes: 1 addition & 1 deletion assets/static/manifest.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions assets/static/vendor.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion assets/statik/statik.go

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions client/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,12 @@ func (pxy *XtcpProxy) InWorkConn(conn frpNet.Conn) {
}
clientConn.SetReadDeadline(time.Time{})
clientConn.Close()

if natHoleRespMsg.Error != "" {
pxy.Error("natHoleRespMsg get error info: %s", natHoleRespMsg.Error)
return
}

pxy.Trace("get natHoleRespMsg, sid [%s], client address [%s]", natHoleRespMsg.Sid, natHoleRespMsg.ClientAddr)

// Send sid to visitor udp address.
Expand Down
5 changes: 5 additions & 0 deletions client/visitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,11 @@ func (sv *XtcpVisitor) handleConn(userConn frpNet.Conn) {
visitorConn.SetReadDeadline(time.Time{})
pool.PutBuf(buf)

if natHoleRespMsg.Error != "" {
sv.Error("natHoleRespMsg get error info: %s", natHoleRespMsg.Error)
return
}

sv.Trace("get natHoleRespMsg, sid [%s], client address [%s]", natHoleRespMsg.Sid, natHoleRespMsg.ClientAddr)

// Close visitorConn, so we can use it's local address.
Expand Down
1 change: 1 addition & 0 deletions cmd/frpc/sub/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ var (
sk string
serverName string
bindAddr string
bindPort int
)

func init() {
Expand Down
2 changes: 2 additions & 0 deletions cmd/frpc/sub/stcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func init() {
stcpCmd.PersistentFlags().StringVarP(&localIp, "local_ip", "i", "127.0.0.1", "local ip")
stcpCmd.PersistentFlags().IntVarP(&localPort, "local_port", "l", 0, "local port")
stcpCmd.PersistentFlags().StringVarP(&bindAddr, "bind_addr", "", "", "bind addr")
stcpCmd.PersistentFlags().IntVarP(&bindPort, "bind_port", "", 0, "bind port")
stcpCmd.PersistentFlags().BoolVarP(&useEncryption, "ue", "", false, "use encryption")
stcpCmd.PersistentFlags().BoolVarP(&useCompression, "uc", "", false, "use compression")

Expand Down Expand Up @@ -69,6 +70,7 @@ var stcpCmd = &cobra.Command{
cfg.LocalIp = localIp
cfg.LocalPort = localPort
cfg.BindAddr = bindAddr
cfg.BindPort = bindPort
cfg.UseEncryption = useEncryption
cfg.UseCompression = useCompression

Expand Down
2 changes: 2 additions & 0 deletions cmd/frpc/sub/xtcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func init() {
xtcpCmd.PersistentFlags().StringVarP(&localIp, "local_ip", "i", "127.0.0.1", "local ip")
xtcpCmd.PersistentFlags().IntVarP(&localPort, "local_port", "l", 0, "local port")
xtcpCmd.PersistentFlags().StringVarP(&bindAddr, "bind_addr", "", "", "bind addr")
xtcpCmd.PersistentFlags().IntVarP(&bindPort, "bind_port", "", 0, "bind port")
xtcpCmd.PersistentFlags().BoolVarP(&useEncryption, "ue", "", false, "use encryption")
xtcpCmd.PersistentFlags().BoolVarP(&useCompression, "uc", "", false, "use compression")

Expand Down Expand Up @@ -69,6 +70,7 @@ var xtcpCmd = &cobra.Command{
cfg.LocalIp = localIp
cfg.LocalPort = localPort
cfg.BindAddr = bindAddr
cfg.BindPort = bindPort
cfg.UseEncryption = useEncryption
cfg.UseCompression = useCompression

Expand Down
2 changes: 1 addition & 1 deletion cmd/frps/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func init() {
rootCmd.PersistentFlags().StringVarP(&logWay, "log_way", "", "console", "log way")
rootCmd.PersistentFlags().StringVarP(&logLevel, "log_level", "", "info", "log level")
rootCmd.PersistentFlags().Int64VarP(&logMaxDays, "log_max_days", "", 3, "log_max_days")
rootCmd.PersistentFlags().StringVarP(&token, "token", "", "", "auth token")
rootCmd.PersistentFlags().StringVarP(&token, "token", "t", "", "auth token")
rootCmd.PersistentFlags().Int64VarP(&authTimeout, "auth_timeout", "", 900, "auth timeout")
rootCmd.PersistentFlags().StringVarP(&subDomainHost, "subdomain_host", "", "", "subdomain host")
rootCmd.PersistentFlags().Int64VarP(&maxPortsPerClient, "max_ports_per_client", "", 0, "max ports per client")
Expand Down
12 changes: 10 additions & 2 deletions models/config/proxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func (cfg *DomainConf) checkForSvr() (err error) {

if cfg.SubDomain != "" {
if subDomainHost == "" {
return fmt.Errorf("subdomain is not supported because this feature is not enabled by frps")
return fmt.Errorf("subdomain is not supported because this feature is not enabled in remote frps")
}
if strings.Contains(cfg.SubDomain, ".") || strings.Contains(cfg.SubDomain, "*") {
return fmt.Errorf("'.' and '*' is not supported in subdomain")
Expand Down Expand Up @@ -509,7 +509,7 @@ func (cfg *HttpProxyConf) CheckForCli() (err error) {

func (cfg *HttpProxyConf) CheckForSvr() (err error) {
if vhostHttpPort == 0 {
err = fmt.Errorf("type [http] not support when vhost_http_port is not set")
return fmt.Errorf("type [http] not support when vhost_http_port is not set")
}
if err = cfg.DomainConf.checkForSvr(); err != nil {
err = fmt.Errorf("proxy [%s] domain conf check error: %v", cfg.ProxyName, err)
Expand Down Expand Up @@ -675,6 +675,10 @@ func (cfg *StcpProxyConf) CheckForCli() (err error) {
err = fmt.Errorf("bind_addr shouldn't be empty")
return
}
if cfg.BindPort == 0 {
err = fmt.Errorf("bind_port should be set")
return
}
}
return
}
Expand Down Expand Up @@ -777,6 +781,10 @@ func (cfg *XtcpProxyConf) CheckForCli() (err error) {
err = fmt.Errorf("bind_addr shouldn't be empty")
return
}
if cfg.BindPort == 0 {
err = fmt.Errorf("bind_port should be set")
return
}
}
return
}
Expand Down
1 change: 1 addition & 0 deletions models/msg/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ type NatHoleResp struct {
Sid string `json:"sid"`
VisitorAddr string `json:"visitor_addr"`
ClientAddr string `json:"client_addr"`
Error string `json:"error"`
}

type NatHoleSid struct {
Expand Down
36 changes: 29 additions & 7 deletions server/nathole.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,21 @@ func (nc *NatHoleController) HandleVisitor(m *msg.NatHoleVisitor, raddr *net.UDP
}
nc.mu.Lock()
clientCfg, ok := nc.clientCfgs[m.ProxyName]
if !ok || m.SignKey != util.GetAuthKey(clientCfg.Sk, m.Timestamp) {
if !ok {
nc.mu.Unlock()
errInfo := fmt.Sprintf("xtcp server for [%s] doesn't exist", m.ProxyName)
log.Debug(errInfo)
nc.listener.WriteToUDP(nc.GenNatHoleResponse(nil, errInfo), raddr)
return
}
if m.SignKey != util.GetAuthKey(clientCfg.Sk, m.Timestamp) {
nc.mu.Unlock()
errInfo := fmt.Sprintf("xtcp connection of [%s] auth failed", m.ProxyName)
log.Debug(errInfo)
nc.listener.WriteToUDP(nc.GenNatHoleResponse(nil, errInfo), raddr)
return
}

nc.sessions[sid] = session
nc.mu.Unlock()
log.Trace("handle visitor message, sid [%s]", sid)
Expand All @@ -130,7 +141,7 @@ func (nc *NatHoleController) HandleVisitor(m *msg.NatHoleVisitor, raddr *net.UDP
// Wait client connections.
select {
case <-session.NotifyCh:
resp := nc.GenNatHoleResponse(raddr, session)
resp := nc.GenNatHoleResponse(session, "")
log.Trace("send nat hole response to visitor")
nc.listener.WriteToUDP(resp, raddr)
case <-time.After(time.Duration(NatHoleTimeout) * time.Second):
Expand All @@ -149,16 +160,27 @@ func (nc *NatHoleController) HandleClient(m *msg.NatHoleClient, raddr *net.UDPAd
session.ClientAddr = raddr
session.NotifyCh <- struct{}{}

resp := nc.GenNatHoleResponse(raddr, session)
resp := nc.GenNatHoleResponse(session, "")
log.Trace("send nat hole response to client")
nc.listener.WriteToUDP(resp, raddr)
}

func (nc *NatHoleController) GenNatHoleResponse(raddr *net.UDPAddr, session *NatHoleSession) []byte {
func (nc *NatHoleController) GenNatHoleResponse(session *NatHoleSession, errInfo string) []byte {
var (
sid string
visitorAddr string
clientAddr string
)
if session != nil {
sid = session.Sid
visitorAddr = session.VisitorAddr.String()
clientAddr = session.ClientAddr.String()
}
m := &msg.NatHoleResp{
Sid: session.Sid,
VisitorAddr: session.VisitorAddr.String(),
ClientAddr: session.ClientAddr.String(),
Sid: sid,
VisitorAddr: visitorAddr,
ClientAddr: clientAddr,
Error: errInfo,
}
b := bytes.NewBuffer(nil)
err := msg.WriteMsg(b, m)
Expand Down
6 changes: 3 additions & 3 deletions utils/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"strings"
)

var version string = "0.19.0"
var version string = "0.19.1"

func Full() string {
return version
Expand Down Expand Up @@ -48,8 +48,8 @@ func Minor(v string) int64 {

// add every case there if server will not accept client's protocol and return false
func Compat(client string) (ok bool, msg string) {
if LessThan(client, "0.10.0") {
return false, "Please upgrade your frpc version to at least 0.10.0"
if LessThan(client, "0.18.0") {
return false, "Please upgrade your frpc version to at least 0.18.0"
}
return true, ""
}
Expand Down
2 changes: 1 addition & 1 deletion utils/version/version_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,5 +61,5 @@ func TestCompact(t *testing.T) {
assert.True(ok)

ok, _ = Compat("0.10.0")
assert.True(ok)
assert.False(ok)
}
1 change: 0 additions & 1 deletion utils/vhost/newhttp.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ func getHostFromAddr(addr string) (host string) {

type HttpReverseProxy struct {
proxy *ReverseProxy
tr *http.Transport

vhostRouter *VhostRouters

Expand Down
11 changes: 10 additions & 1 deletion web/frps/.babelrc
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
{
"presets": [
["es2015", { "modules": false }]
],
"plugins": [
[
"component",
{
"libraryName": "element-ui",
"styleLibraryName": "theme-chalk"
}
]
]
}
}
Loading

0 comments on commit da78e3f

Please sign in to comment.