Use pointer instead of struct
This commit is contained in:
parent
853477e54a
commit
6d8f38d749
18 changed files with 187 additions and 142 deletions
|
@ -12,12 +12,12 @@ import (
|
|||
|
||||
func init() {
|
||||
router.GET("/api/ips", apiHandler(showIPs))
|
||||
router.GET("/api/students/:sid/ips", apiHandler(studentHandler(func(student adlin.Student, body []byte) (interface{}, error) {
|
||||
router.GET("/api/students/:sid/ips", apiHandler(studentHandler(func(student *adlin.Student, body []byte) (interface{}, error) {
|
||||
return getStudentIPs(student), nil
|
||||
})))
|
||||
}
|
||||
|
||||
func IPSuffix(s adlin.Student, network net.IPNet) net.IP {
|
||||
func IPSuffix(s *adlin.Student, network net.IPNet) net.IP {
|
||||
ipshift := s.Id*4 + 10
|
||||
|
||||
myIP := network.IP
|
||||
|
@ -55,7 +55,7 @@ func showIPs(_ httprouter.Params, body []byte) (interface{}, error) {
|
|||
return r, nil
|
||||
}
|
||||
|
||||
func GetStudentTunnelIPs(student adlin.Student) (ips []string) {
|
||||
func GetStudentTunnelIPs(student *adlin.Student) (ips []string) {
|
||||
if ts, err := student.GetActivesTunnels(); err != nil || len(ts) == 0 || ts[0].SuffixIP == 0 {
|
||||
ips = append(ips, adlin.StudentIP(student.Id).String()+"1")
|
||||
} else {
|
||||
|
@ -66,7 +66,7 @@ func GetStudentTunnelIPs(student adlin.Student) (ips []string) {
|
|||
return
|
||||
}
|
||||
|
||||
func getStudentIPs(student adlin.Student) (r map[string]string) {
|
||||
func getStudentIPs(student *adlin.Student) (r map[string]string) {
|
||||
r = make(map[string]string)
|
||||
|
||||
r["vlan0"] = IPSuffix(student, net.IPNet{net.ParseIP("172.23.0.0"), net.CIDRMask(17, 32)}).String()
|
||||
|
|
Reference in a new issue