@@ -32,30 +32,24 @@ import (
3232 "istio.io/istio/pkg/filewatcher"
3333
3434 "kmesh.net/kmesh/pkg/constants"
35+ "kmesh.net/kmesh/pkg/controller/encryption"
3536 "kmesh.net/kmesh/pkg/kube/apis/kmeshnodeinfo/v1alpha1"
3637)
3738
3839const (
3940 IpSecKeyFile = "./kmesh-ipsec/ipSec"
4041)
4142
42- type IpSecKey struct {
43- Spi int `json:"spi"`
44- AeadKeyName string `json:"aeadKeyName"`
45- AeadKey []byte `json:"aeadKey"`
46- Length int `json:"length"`
47- }
48-
4943type IpSecHandler struct {
5044 Spi int
5145 mutex sync.RWMutex
5246 watcher filewatcher.FileWatcher
53- historyIpSecKey map [int ]IpSecKey
47+ historyIpSecKey map [int ]encryption. IpSecKey
5448}
5549
5650func NewIpSecHandler () * IpSecHandler {
5751 return & IpSecHandler {
58- historyIpSecKey : make (map [int ]IpSecKey ),
52+ historyIpSecKey : make (map [int ]encryption. IpSecKey ),
5953 }
6054}
6155
@@ -76,7 +70,7 @@ func (is *IpSecHandler) LoadIPSecKeyFromFile(filePath string) error {
7670func (is * IpSecHandler ) loadIPSecKeyFromIO (file * os.File ) error {
7771 reader := bufio .NewReader (file )
7872 decoder := json .NewDecoder (reader )
79- var key IpSecKey
73+ var key encryption. IpSecKey
8074 if err := decoder .Decode (& key ); err != nil {
8175 return fmt .Errorf ("ipsec config file decoder error, %v, please use Kmesh tool generate ipsec secret key" , err )
8276 }
@@ -231,7 +225,7 @@ func (is *IpSecHandler) createXfrmRuleIngress(rawRemoteIP, rawLocalNicIP, remote
231225 * ip xfrm state add src {localNicIP} dst {remoteNicIP} proto esp spi {remoteSpi} mode tunnel reqid 1 {aead-algo} {aead-key} {aead-key-length}
232226 * ip xfrm policy add src 0.0.0.0/0 dst {remoteCIDR} dir out tmpl src {localNicIP} dst {remoteNicIP} proto esp spi {remoteSpi} reqid 1 mode tunnel mark 0x{remoteNodeID}00e0
233227 */
234- func (is * IpSecHandler ) createXfrmRuleEgress (rawLocalNicIP , rawRemoteIP , localBootID , remoteBootID string , ipsecKey IpSecKey , podCIDRs []string ) error {
228+ func (is * IpSecHandler ) createXfrmRuleEgress (rawLocalNicIP , rawRemoteIP , localBootID , remoteBootID string , ipsecKey encryption. IpSecKey , podCIDRs []string ) error {
235229 src := net .ParseIP (rawLocalNicIP )
236230 if src == nil {
237231 return fmt .Errorf ("failed to parser ip in inserting xfrm rule, input: %v" , rawLocalNicIP )
@@ -267,7 +261,7 @@ func (is *IpSecHandler) createXfrmRuleEgress(rawLocalNicIP, rawRemoteIP, localBo
267261 return nil
268262}
269263
270- func (is * IpSecHandler ) createStateRule (src net.IP , dst net.IP , key []byte , ipsecKey IpSecKey , ingress bool ) error {
264+ func (is * IpSecHandler ) createStateRule (src net.IP , dst net.IP , key []byte , ipsecKey encryption. IpSecKey , ingress bool ) error {
271265 state := & netlink.XfrmState {
272266 Src : src ,
273267 Dst : dst ,
0 commit comments