Skip to content

Commit

Permalink
modify template to proper toml format (#6)
Browse files Browse the repository at this point in the history
Existing config that is generated is not processed correctly with latest version of frp (v0.58.1) due to formatting.

Signed-off-by: Eddie Garcia <jinyx007@gmail.com>
  • Loading branch information
JinxCappa authored Jun 28, 2024
1 parent 307e67d commit ff910a6
Showing 1 changed file with 15 additions and 16 deletions.
31 changes: 15 additions & 16 deletions pkg/client/utils/template.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,32 @@ package utils

const CLIENT_TEMPLATE = `
# frpc.toml
[common]
serverAddr = {{ .Common.ServerAddress }}
serverAddr = "{{ .Common.ServerAddress }}"
serverPort = {{ .Common.ServerPort }}
{{ if eq .Common.ServerAuthentication.Type 1 }}
auth.method = "token"
auth.token = {{ .Common.ServerAuthentication.Token }}
auth.token = "{{ .Common.ServerAuthentication.Token }}"
{{ end }}
webServer.addr = {{ .Common.AdminAddress }}
webServer.addr = "{{ .Common.AdminAddress }}"
webServer.port = {{ .Common.AdminPort }}
webServer.user = {{ .Common.AdminUsername }}
webServer.password = {{ .Common.AdminPassword }}
webServer.user = "{{ .Common.AdminUsername }}"
webServer.password = "{{ .Common.AdminPassword }}"
{{ range $upstream := .Upstreams }}
[{{ $upstream.Name }}]
[[proxies]]
{{ if eq $upstream.Type 1 }}
name = {{ $upstream.Name }}
type = tcp
localIP = {{ $upstream.TCP.Host }}
name = "{{ $upstream.Name }}"
type = "tcp"
localIP = "{{ $upstream.TCP.Host }}"
localPort = {{ $upstream.TCP.Port }}
remotePort = {{ $upstream.TCP.ServerPort }}
{{ if $upstream.TCP.ProxyProtocol }}
transport.proxyProtocolVersion = {{ $upstream.TCP.ProxyProtocol }}
transport.proxyProtocolVersion = "{{ $upstream.TCP.ProxyProtocol }}"
{{ end }}
Expand All @@ -43,11 +42,11 @@ transport.useEncryption = true
{{ end }}
{{ if eq $upstream.Type 2 }}
name = {{ $upstream.Name }}
type = udp
localIP = {{ $upstream.TCP.Host }}
localPort = {{ $upstream.TCP.Port }}
remotePort = {{ $upstream.TCP.ServerPort }}
name = "{{ $upstream.Name }}"
type = "udp"
localIP = "{{ $upstream.UDP.Host }}"
localPort = {{ $upstream.UDP.Port }}
remotePort = {{ $upstream.UDP.ServerPort }}
{{ end }}
{{ end }}
Expand Down

0 comments on commit ff910a6

Please sign in to comment.