Skip to content
This repository has been archived by the owner on Jan 4, 2023. It is now read-only.

Commit

Permalink
Merge pull request #11 from hossinasaadi/limit-connection
Browse files Browse the repository at this point in the history
fix IP Restrict Bug
  • Loading branch information
hossinasaadi authored Nov 5, 2022
2 parents b95a8ec + 44ca9cc commit 10613bd
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions web/job/check_clinet_ip_job.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,26 @@ func LimitDevice(){

<-c.Start()
if len(c.Status().Stdout) > 0 {
ipRegx, _ := regexp.Compile(`[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+`)
portRegx, _ := regexp.Compile(`(?:(:))([0-9]..[^.][0-9]+)`)

for _, row := range c.Status().Stdout {

data := strings.Split(row," ")

dest,src := strings.Split(data[0],":"),strings.Split(data[1],":")
destIp,destPort,srcIp,srcPort := "","","",""


destIp = string(ipRegx.FindString(data[0]))

destPort = portRegx.FindString(data[0])
destPort = strings.Replace(destPort,":","",-1)


destIp,destPort := dest[0],dest[1]
srcIp,srcPort := src[0],src[1]
srcIp = string(ipRegx.FindString(data[1]))

srcPort = portRegx.FindString(data[1])
srcPort = strings.Replace(srcPort,":","",-1)

if(contains(disAllowedIps,srcIp)){
dropCmd := cmd.NewCmd("bash","-c","ss -K dport = " + srcPort)
Expand Down

0 comments on commit 10613bd

Please sign in to comment.