Go语言RPC Authorization进行简单ip安全验证的方法

2020-01-28 11:21:52王冬梅

                }
            }else{
                fmt.Printf( "Contains ip " )
                if ipNet.Contains( rAddr ) {
                    authorized =true
                }
            }
        }
        if authorized == true{
            curTime:=time.Now()
            fmt.Printf( curTime.Format( "2006-01-02 15:04:05" )  )
            conn.Write( []byte(curTime.Format( "2006-01-02 15:04:05" ) ) )
            time.Sleep( 10)
        }else{
            conn.Close()
        }
    }
}

希望本文所述对大家的Go语言程序设计有所帮助。