Skip to content

Commit

Permalink
refactor: ifelse (fatedier#3224)
Browse files Browse the repository at this point in the history
  • Loading branch information
blizard863 authored Dec 22, 2022
1 parent e2d28d9 commit 804f291
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
7 changes: 4 additions & 3 deletions cmd/frpc/sub/stcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ var stcpCmd = &cobra.Command{
prefix = user + "."
}

if role == "server" {
switch role {
case "server":
cfg := &config.STCPProxyConf{}
cfg.ProxyName = prefix + proxyName
cfg.ProxyType = consts.STCPProxy
Expand All @@ -75,7 +76,7 @@ var stcpCmd = &cobra.Command{
os.Exit(1)
}
proxyConfs[cfg.ProxyName] = cfg
} else if role == "visitor" {
case "visitor":
cfg := &config.STCPVisitorConf{}
cfg.ProxyName = prefix + proxyName
cfg.ProxyType = consts.STCPProxy
Expand All @@ -92,7 +93,7 @@ var stcpCmd = &cobra.Command{
os.Exit(1)
}
visitorConfs[cfg.ProxyName] = cfg
} else {
default:
fmt.Println("invalid role")
os.Exit(1)
}
Expand Down
7 changes: 4 additions & 3 deletions cmd/frpc/sub/sudp.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ var sudpCmd = &cobra.Command{
prefix = user + "."
}

if role == "server" {
switch role {
case "server":
cfg := &config.SUDPProxyConf{}
cfg.ProxyName = prefix + proxyName
cfg.ProxyType = consts.SUDPProxy
Expand All @@ -75,7 +76,7 @@ var sudpCmd = &cobra.Command{
os.Exit(1)
}
proxyConfs[cfg.ProxyName] = cfg
} else if role == "visitor" {
case "visitor":
cfg := &config.SUDPVisitorConf{}
cfg.ProxyName = prefix + proxyName
cfg.ProxyType = consts.SUDPProxy
Expand All @@ -92,7 +93,7 @@ var sudpCmd = &cobra.Command{
os.Exit(1)
}
visitorConfs[cfg.ProxyName] = cfg
} else {
default:
fmt.Println("invalid role")
os.Exit(1)
}
Expand Down
7 changes: 4 additions & 3 deletions cmd/frpc/sub/xtcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ var xtcpCmd = &cobra.Command{
prefix = user + "."
}

if role == "server" {
switch role {
case "server":
cfg := &config.XTCPProxyConf{}
cfg.ProxyName = prefix + proxyName
cfg.ProxyType = consts.XTCPProxy
Expand All @@ -75,7 +76,7 @@ var xtcpCmd = &cobra.Command{
os.Exit(1)
}
proxyConfs[cfg.ProxyName] = cfg
} else if role == "visitor" {
case "visitor":
cfg := &config.XTCPVisitorConf{}
cfg.ProxyName = prefix + proxyName
cfg.ProxyType = consts.XTCPProxy
Expand All @@ -92,7 +93,7 @@ var xtcpCmd = &cobra.Command{
os.Exit(1)
}
visitorConfs[cfg.ProxyName] = cfg
} else {
default:
fmt.Println("invalid role")
os.Exit(1)
}
Expand Down

0 comments on commit 804f291

Please sign in to comment.