コード例 #1
0
ファイル: client.go プロジェクト: zalando/baboon-proxy
// LTMBlockIPPatch add ips which will be blocked
func LTMBlockIPPatch(c *gin.Context) {
	var blockips ltm.CreateAddresses

	f5url, err := ltm.Loadbalancer(c.Params.ByName("lbpair"), conf.Ltmdevicenames)
	if err != nil {
		respondWithStatus(err.Status, "", nil, err.Message, conf.Documentation["ltmaddresslistdocumentationuri"], c)
		return
	}
	f5url = util.ReplaceLTMUritoAddressListURI(f5url)
	if err := c.BindJSON(&blockips); err != nil {
		respondWithStatus(http.StatusBadRequest, "Invalid JSON data", "Block IPs",
			fmt.Sprintf("%s", err), conf.Documentation["ltmaddresslistdocumentationuri"], c)
		return
	}
	res, err := ltm.PatchLTMBlockAddresses(f5url, &blockips)
	if err != nil {
		respondWithStatus(err.Status, "", nil, err.Message, conf.Documentation["ltmaddresslistdocumentationuri"], c)
		return
	}
	json.Unmarshal([]byte(res.Body), &returnerror)
	if res.Status == http.StatusOK {
		res.Status = http.StatusCreated
	}
	respondWithStatus(res.Status, "IP(s) blocked successfully", blockips,
		returnerror.ErrorMessage(), conf.Documentation["ltmaddresslistdocumentationuri"], c)
}
コード例 #2
0
ファイル: client.go プロジェクト: zalando/baboon-proxy
// LTMWhiteAddressList show local traffic whitelisted ip addresses
func LTMWhiteAddressList(c *gin.Context) {
	lbpair := c.Params.ByName("lbpair")
	f5url, err := ltm.Loadbalancer(lbpair, conf.Ltmdevicenames)
	if err != nil {
		respondWithStatus(err.Status, "", nil, err.Message, conf.Documentation["ltmaddresslistdocumentationuri"], c)
		return
	}
	f5url = util.ReplaceLTMUritoAddressListURI(f5url)
	res, addresslist, err := ltm.ShowLTMAddressList(f5url, common.WhiteList)
	if err != nil {
		respondWithStatus(err.Status, "", nil, err.Message, conf.Documentation["ltmaddresslistdocumentationuri"], c)
		return
	}
	json.Unmarshal([]byte(res.Body), &returnerror)
	respondWithStatus(res.Status, "", addresslist, returnerror.ErrorMessage(), conf.Documentation["ltmaddresslistdocumentationuri"], c)
}
コード例 #3
0
ファイル: client.go プロジェクト: zalando/baboon-proxy
// LTMRemoveWhiteIPPatch remove ips which are currently whitelisted
func LTMRemoveWhiteIPPatch(c *gin.Context) {
	var removewhiteips ltm.DeleteAddresses

	f5url, err := ltm.Loadbalancer(c.Params.ByName("lbpair"), conf.Ltmdevicenames)
	if err != nil {
		respondWithStatus(err.Status, "", nil, err.Message, conf.Documentation["ltmaddresslistdocumentationuri"], c)
		return
	}
	f5url = util.ReplaceLTMUritoAddressListURI(f5url)
	if err := c.BindJSON(&removewhiteips); err != nil {
		respondWithStatus(http.StatusBadRequest, "Invalid JSON data", "Unblock IPs",
			fmt.Sprintf("%s", err), conf.Documentation["ltmaddresslistdocumentationuri"], c)
		return
	}
	res, err := ltm.DeleteLTMBlockAddresses(f5url, &removewhiteips, common.WhiteList)
	if err != nil {
		respondWithStatus(err.Status, "", nil, err.Message, conf.Documentation["ltmaddresslistdocumentationuri"], c)
		return
	}
	json.Unmarshal([]byte(res.Body), &returnerror)
	respondWithStatus(res.Status, "IP(s) removed successfully from whitelist", fmt.Sprintf("%+v", removewhiteips),
		returnerror.ErrorMessage(), conf.Documentation["ltmaddresslistdocumentationuri"], c)
}