forked from MetaCubeX/mihomo
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'MetaCubeX:Alpha' into Alpha
- Loading branch information
Showing
51 changed files
with
1,206 additions
and
344 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -69,3 +69,5 @@ func WithDSCP(dscp uint8) Addition { | |
metadata.DSCP = dscp | ||
} | ||
} | ||
|
||
func Placeholder(metadata *C.Metadata) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
package cidr | ||
|
||
import ( | ||
"encoding/binary" | ||
"errors" | ||
"io" | ||
"net/netip" | ||
|
||
"go4.org/netipx" | ||
) | ||
|
||
func (ss *IpCidrSet) WriteBin(w io.Writer) (err error) { | ||
// version | ||
_, err = w.Write([]byte{1}) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
// rr | ||
err = binary.Write(w, binary.BigEndian, int64(len(ss.rr))) | ||
if err != nil { | ||
return err | ||
} | ||
for _, r := range ss.rr { | ||
err = binary.Write(w, binary.BigEndian, r.From().As16()) | ||
if err != nil { | ||
return err | ||
} | ||
err = binary.Write(w, binary.BigEndian, r.To().As16()) | ||
if err != nil { | ||
return err | ||
} | ||
} | ||
|
||
return nil | ||
} | ||
|
||
func ReadIpCidrSet(r io.Reader) (ss *IpCidrSet, err error) { | ||
// version | ||
version := make([]byte, 1) | ||
_, err = io.ReadFull(r, version) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if version[0] != 1 { | ||
return nil, errors.New("version is invalid") | ||
} | ||
|
||
ss = NewIpCidrSet() | ||
var length int64 | ||
|
||
// rr | ||
err = binary.Read(r, binary.BigEndian, &length) | ||
if err != nil { | ||
return nil, err | ||
} | ||
if length < 1 { | ||
return nil, errors.New("length is invalid") | ||
} | ||
ss.rr = make([]netipx.IPRange, length) | ||
for i := int64(0); i < length; i++ { | ||
var a16 [16]byte | ||
err = binary.Read(r, binary.BigEndian, &a16) | ||
if err != nil { | ||
return nil, err | ||
} | ||
from := netip.AddrFrom16(a16).Unmap() | ||
err = binary.Read(r, binary.BigEndian, &a16) | ||
if err != nil { | ||
return nil, err | ||
} | ||
to := netip.AddrFrom16(a16).Unmap() | ||
ss.rr[i] = netipx.IPRangeFrom(from, to) | ||
} | ||
|
||
return ss, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.