Skip to content

Commit

Permalink
update frp to v0.54.0 (#3)
Browse files Browse the repository at this point in the history
* update v0.54.0

Signed-off-by: Williams Alejandro <walejandromt@gmail.com>

* Update template.go

Signed-off-by: Williams Alejandro <walejandromt@gmail.com>

---------

Signed-off-by: Williams Alejandro <walejandromt@gmail.com>
Co-authored-by: Zufar Dhiyaulhaq <zufardhiyaulhaq@gmail.com>
  • Loading branch information
walejandromt and zufardhiyaulhaq authored Apr 4, 2024
1 parent 12fd070 commit aea8c5a
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 15 deletions.
3 changes: 3 additions & 0 deletions api/v1alpha1/upstream_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ type UpstreamSpec struct {
}

type UpstreamSpec_TCP struct {
Name string `json:"name"`
Type string `json:"type"`
SubDomain string `json:"subdomain"`
Host string `json:"host"`
Port int `json:"port"`
Server UpstreamSpec_TCP_Server `json:"server"`
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/builder/configmap_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func (n *ConfigMapBuilder) SetNamespace(namespace string) *ConfigMapBuilder {

func (n *ConfigMapBuilder) Build() (*corev1.ConfigMap, error) {
data := make(map[string]string)
data["config.ini"] = n.Config
data["config.toml"] = n.Config

configMap := &corev1.ConfigMap{
ObjectMeta: metav1.ObjectMeta{
Expand Down
2 changes: 1 addition & 1 deletion pkg/client/builder/pod_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (n *PodBuilder) Build() (*corev1.Pod, error) {
{
Name: "frpc",
Image: n.Image,
Command: []string{"frpc", "-c", "/frp/config.ini"},
Command: []string{"frpc", "-c", "/frp/config.toml"},
Ports: []corev1.ContainerPort{
{ContainerPort: int32(4040)},
},
Expand Down
3 changes: 3 additions & 0 deletions pkg/client/models/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ type Upstream struct {
}

type Upstream_TCP struct {
Name string
Type string
SubDomain string
Host string
Port int
ServerPort int
Expand Down
30 changes: 17 additions & 13 deletions pkg/client/utils/template.go
Original file line number Diff line number Diff line change
@@ -1,30 +1,34 @@
package utils

const CLIENT_TEMPLATE = `
# frpc.toml
[common]
server_addr = {{ .Common.ServerAddress }}
server_port = {{ .Common.ServerPort }}
serverAddr = {{ .Common.ServerAddress }}
serverPort = {{ .Common.ServerPort }}
{{ if eq .Common.ServerAuthentication.Type 1 }}
token = {{ .Common.ServerAuthentication.Token }}
auth.method = "token"
auth.token = {{ .Common.ServerAuthentication.Token }}
{{ end }}
admin_addr = {{ .Common.AdminAddress }}
admin_port = {{ .Common.AdminPort }}
admin_user = {{ .Common.AdminUsername }}
admin_pwd = {{ .Common.AdminPassword }}
webServer.addr = {{ .Common.AdminAddress }}
webServer.port = {{ .Common.AdminPort }}
webServer.user = {{ .Common.AdminUsername }}
webServer.password = {{ .Common.AdminPassword }}
{{ range $upstream := .Upstreams }}
[{{ $upstream.Name }}]
{{ if eq $upstream.Type 1 }}
type = tcp
local_ip = {{ $upstream.TCP.Host }}
local_port = {{ $upstream.TCP.Port }}
remote_port = {{ $upstream.TCP.ServerPort }}
name = {{ $upstream.TCP.Name }}
type = {{ $upstream.TCP.Type }}
subdomain = {{ $upstream.TCP.SubDomain }}
localIP = {{ $upstream.TCP.Host }}
localPort = {{ $upstream.TCP.Port }}
remotePort = {{ $upstream.TCP.ServerPort }}
{{ if $upstream.TCP.ProxyProtocol }}
proxy_protocol_version = {{ $upstream.TCP.ProxyProtocol }}
transport.proxyProtocolVersion = {{ $upstream.TCP.ProxyProtocol }}
{{ end }}
use_encryption = true
transport.useEncryption = true
{{ end }}
{{ end }}
`

0 comments on commit aea8c5a

Please sign in to comment.