Compare commits

...

4 Commits

Author SHA1 Message Date
Toby 0daaa32fc6 ci: install pcap for build 2 2024-05-07 23:13:58 -07:00
Toby 5e15fd6dd9 ci: install pcap for build 2024-05-07 23:12:24 -07:00
Toby 76c0f47832 chore: do not default replay.realtime to true 2024-05-07 23:05:06 -07:00
Toby 70fee14103 chore: format 2024-05-07 22:50:58 -07:00
4 changed files with 15 additions and 9 deletions

View File

@ -23,6 +23,9 @@ jobs:
with:
go-version: 'stable'
- name: Install pcap
run: sudo apt install -y libpcap-dev
- run: go vet ./...
- name: staticcheck
@ -44,4 +47,7 @@ jobs:
with:
go-version: 'stable'
- name: Install pcap
run: sudo apt install -y libpcap-dev
- run: go test ./...

View File

@ -24,6 +24,9 @@ jobs:
with:
go-version: "1.22"
- name: Install pcap
run: sudo apt install -y libpcap-dev
- name: Build
env:
GOOS: ${{ matrix.goos }}

View File

@ -135,8 +135,6 @@ func initConfig() {
viper.AddConfigPath("$HOME/.opengfw")
viper.AddConfigPath("/etc/opengfw")
}
viper.SetDefault("replay.realtime", true)
}
func initLogger() {
@ -183,7 +181,7 @@ type cliConfigIO struct {
}
type cliConfigReplay struct {
Realtime bool `mapstructure:"realtime"`
Realtime bool `mapstructure:"realtime"`
}
type cliConfigWorkers struct {
@ -212,8 +210,8 @@ func (c *cliConfig) fillIO(config *engine.Config) error {
// Setup IO for pcap file replay
logger.Info("replaying from pcap file", zap.String("pcap file", pcapFile))
ioImpl, err = io.NewPcapPacketIO(io.PcapPacketIOConfig{
PcapFile: pcapFile,
Realtime: c.Replay.Realtime,
PcapFile: pcapFile,
Realtime: c.Replay.Realtime,
})
} else {
// Setup IO for nfqueue

View File

@ -20,17 +20,16 @@ type pcapPacketIO struct {
ioCancel context.CancelFunc
config PcapPacketIOConfig
dialer *net.Dialer
dialer *net.Dialer
}
type PcapPacketIOConfig struct {
PcapFile string
Realtime bool
PcapFile string
Realtime bool
}
func NewPcapPacketIO(config PcapPacketIOConfig) (PacketIO, error) {
handle, err := pcap.OpenOffline(config.PcapFile)
if err != nil {
return nil, err
}