Skip to content

Commit

Permalink
fix example, cleanup comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sergle committed Oct 5, 2020
1 parent cf53360 commit e51b4a8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 13 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ package main
import (
"fmt"
"github.com/sergle/radius"
"github.com/sergle/radius/client"
)

func main() {
Expand All @@ -130,7 +129,7 @@ func main() {
return
}

client := client.NewClient("127.0.0.1:1812", "gother")
client := radius.NewRadClient("127.0.0.1:1812", "secret")

request := client.NewRequest(radius.DisconnectRequest)
request.AddAVP( dict.NewAVP("Acct-Session-Id", "100500") )
Expand Down
2 changes: 1 addition & 1 deletion eap.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func (a *EapPacket) String() string {
func (a *EapPacket) valueString() string {
switch a.Type {
case EapTypeIdentity:
return fmt.Sprintf("%#v", string(a.Data)) //应该是字符串,但是也有可能被搞错
return fmt.Sprintf("%#v", string(a.Data)) //It should be a string, but it may be mistaken
case EapTypeMSCHAPV2:
mcv, err := MsChapV2PacketFromEap(a)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions msChapv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

type MsChapV2Packet struct {
Eap *EapPacket //解密的时候的eap信息,不使用里面的data
Eap *EapPacket //The eap information when decrypting, does not use the data inside
OpCode MsChapV2OpCode
Data []byte
}
Expand All @@ -34,7 +34,7 @@ func MsChapV2PacketFromEap(eap *EapPacket) (p *MsChapV2Packet, err error) {
return p, nil
}

//不包括eap的信息
//Does not include eap information
func (p *MsChapV2Packet) String() string {
return fmt.Sprintf("OpCode:%s Data:[%#v]", p.OpCode, p.Data)
}
Expand Down
12 changes: 4 additions & 8 deletions packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ func (p *Packet) Copy() *Packet {
Secret: p.Secret,
Code: p.Code,
Identifier: p.Identifier,
Authenticator: p.Authenticator, //这个应该是拷贝
Authenticator: p.Authenticator, // This should be a copy
}
outP.AVPs = make([]AVP, len(p.AVPs))
for i := range p.AVPs {
Expand All @@ -40,8 +40,7 @@ func (p *Packet) Copy() *Packet {
return outP
}

//此方法保证不修改包的内容
//This method does not modify the contents of the package to ensure
//This method guarantees that the contents of the package are not modified
func (p *Packet) Encode() (b []byte, err error) {
// do not copy
// p = p.Copy()
Expand All @@ -61,7 +60,6 @@ func (p *Packet) Encode() (b []byte, err error) {
}
}

//TODO request的时候重新计算密码
// When the password request recalculation
b, err = p.encodeNoHash()
if err != nil {
Expand Down Expand Up @@ -155,8 +153,7 @@ func (p *Packet) AddVSA(vsa VSA) {
p.AddAVP(vsa.ToAVP())
}

//删除一个AVP
//Delete a AVP
//Delete one AVP
func (p *Packet) DeleteAVP(avp *AVP) {
for i := range p.AVPs {
if &(p.AVPs[i]) == avp {
Expand Down Expand Up @@ -259,8 +256,7 @@ func decodePacket(Secret string, buf []byte, request_auth []byte) (p *Packet, er
b = b[length:]
}

//验证Message-Authenticator,并且通过测试验证此处算法是正确的
//Verify Message-Authenticator, and tested to verify the algorithm is correct here
//Verify the Message-Authenticator and verify that the algorithm here is correct through testing
err = p.checkMessageAuthenticator(request_auth)
if err != nil {
return p, err
Expand Down

0 comments on commit e51b4a8

Please sign in to comment.