// 2019 Rackspace, Inc. // // Licensed under the Apache License, Version 2.0 (the "License"): you may // not use this file except in compliance with the License. You may obtain // a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the // License for the specific language governing permissions and limitations // under the License. package tsip import ( "fmt" "github.com/sirupsen/logrus" "github.rackspace.com/gorax/f5api/pkg" ) // TODO: Add SNAT and SNAT Pool lookups func (c *Client) lookupF5(r *RealIP) error { device, err := pkg.InitF5(c.core, r.Gateway.ID, "", false) if err != nil { logrus.Errorf("%s:lookupF5:InitF5:%s", r.MappedAddress, err) return errConnect } if err = device.NatConfig("", "", 60); err != nil { logrus.Errorf("%s:lookupF5:NatConfig:%s", r.MappedAddress, err) return errGather } for _, nat := range device.Config.Nat { if nat.TranslationAddr == r.Device.addrObj.String() { r.RealAddress = []string{nat.OriginatingAddr} return nil } } if len(r.RealAddress) == 0 { r.Details = errNoXlate.Error() r.RealAddress = []string{fmt.Sprintf("%s/32", r.MappedAddress)} } return nil }