Skip to content

Commit

Permalink
fix: same remote with diff secret for diff protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
danieldin95 committed Jun 22, 2024
1 parent 94f7e32 commit 33d27ed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
3 changes: 3 additions & 0 deletions pkg/config/ipsec.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ func (s *IPSecTunnel) Correct() {
s.Left = "%defaultroute"
}
s.Name = s.Id()
if s.RightId == "" {
s.RightId = s.Right
}
}

func (s *IPSecTunnel) Id() string {
Expand Down
14 changes: 7 additions & 7 deletions pkg/switch/ipsec.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ conn {{ .Name }}-c1
auto=add
also={{ .Name }}
{{- if .LeftId }}
leftid=@c1.{{ .LeftId }}
leftid=@c1.{{ .LeftId }}.{{ .Transport }}
{{- end }}
{{- if .RightId }}
rightid=@c2.{{ .RightId }}
rightid=@c2.{{ .RightId }}.{{ .Transport }}
{{- end }}
leftprotoport=udp/8472
rightprotoport=udp
Expand All @@ -63,10 +63,10 @@ conn {{ .Name }}-c2
auto=add
also={{ .Name }}
{{- if .LeftId }}
leftid=@c2.{{ .LeftId }}
leftid=@c2.{{ .LeftId }}.{{ .Transport }}
{{- end }}
{{- if .RightId }}
rightid=@c1.{{ .RightId }}
rightid=@c1.{{ .RightId }}.{{ .Transport }}
{{- end }}
leftprotoport=udp
rightprotoport=udp/8472
Expand All @@ -81,11 +81,11 @@ conn {{ .Name }}-c1
leftikeport={{ .LeftPort }}
{{- end }}
{{- if .LeftId }}
leftid=@{{ .LeftId }}
leftid=@{{ .LeftId }}.{{ .Transport }}
{{- end }}
right={{ .Right }}
{{- if .RightId }}
rightid=@{{ .RightId }}
rightid=@{{ .RightId }}.{{ .Transport }}
{{- end }}
{{- if .RightPort }}
rightikeport={{ .RightPort }}
Expand All @@ -95,7 +95,7 @@ conn {{ .Name }}-c1
rightprotoport=gre
`
secretTmpl = `
%any {{ .Right }} : PSK "{{ .Secret }}"
%any {{ .RightId }}.{{ .Transport }} : PSK "{{ .Secret }}"
`
)

Expand Down

0 comments on commit 33d27ed

Please sign in to comment.