Exemplo n.º 1
0
func (s *ShittyNetworkSymptom) Teardown() {
	log.Debug("Tearing down ShittyNetworkSymptom")
	s.config.Stop = true
	supressOutput(func() {
		throttler.Run(&s.config)
	})
}
Exemplo n.º 2
0
func main() {
	// TODO: Add support for other options like packet reordering, duplication, etc.
	var (
		device      = flag.String("device", "", "Interface (device) to use (defaults to eth0 where applicable)")
		mode        = flag.String("mode", throttler.Start, "Start or stop packet controls")
		latency     = flag.Int("latency", -1, "Latency to add in ms")
		targetbw    = flag.Int("target-bw", -1, "Target bandwidth limit in kbit/s (slow-lane)")
		defaultbw   = flag.Int("default-bw", -1, "Default bandwidth limit in kbit/s (fast-lane)")
		packetLoss  = flag.String("packet-loss", "0", "Packet loss percentage (eg: 0.1%%)")
		targetaddr  = flag.String("target-addr", "", "Target addresses, (eg: 10.0.0.1 or 10.0.0.0/24 or 10.0.0.1,192.168.0.0/24 or 2001:db8:a::123)")
		targetport  = flag.String("target-port", "", "Target port(s) (eg: 80 or 1:65535 or 22,80,443,1000:1010)")
		targetproto = flag.String("target-proto", "tcp,udp,icmp", "Target protocol TCP/UDP (eg: tcp or tcp,udp or icmp)")
		dryrun      = flag.Bool("dry-run", false, "Specifies whether or not to actually commit the rule changes")
		//icmptype    = flag.String("icmp-type", "", "icmp message type (eg: reply or reply,request)") //TODO: Maybe later :3
	)
	flag.Parse()

	targetIPv4, targetIPv6 := parseAddrs(*targetaddr)

	throttler.Run(&throttler.Config{
		Device:           *device,
		Mode:             *mode,
		Latency:          *latency,
		TargetBandwidth:  *targetbw,
		DefaultBandwidth: *defaultbw,
		PacketLoss:       parseLoss(*packetLoss),
		TargetIps:        targetIPv4,
		TargetIps6:       targetIPv6,
		TargetPorts:      parsePorts(*targetport),
		TargetProtos:     parseProtos(*targetproto),
		DryRun:           *dryrun,
	})
}
Exemplo n.º 3
0
func main() {
	// TODO: add support for specific host/port.
	// Also support for other options like packet reordering, duplication, etc.
	var (
		mode       = flag.String("mode", throttler.Start, "start or stop packet controls")
		latency    = flag.Int("latency", -1, "latency to add in ms")
		bandwidth  = flag.Int("bandwidth", -1, "bandwidth limit in kb/s")
		packetLoss = flag.Float64("packet-loss", 0, "packet-loss rate")
	)
	flag.Parse()

	throttler.Run(&throttler.Config{
		Mode:       *mode,
		Latency:    *latency,
		Bandwidth:  *bandwidth,
		PacketLoss: *packetLoss,
	})
}
Exemplo n.º 4
0
func (s *ShittyNetworkSymptom) Setup() {
	log.Debug("Setting up ShittyNetworkSymptom: Enabling firewall")

	s.config = throttler.Config{
		Device:           s.Device,
		Latency:          s.Latency,
		TargetBandwidth:  s.TargetBandwidth,
		DefaultBandwidth: s.DefaultBandwidth,
		PacketLoss:       s.PacketLoss,
		TargetIps:        s.TargetIps,
		TargetIps6:       s.TargetIps6,
		TargetPorts:      s.TargetPorts,
		TargetProtos:     s.TargetProtos,
		DryRun:           false,
	}

	supressOutput(func() {
		throttler.Run(&s.config)
	})

}
Exemplo n.º 5
0
func (s *ShittyNetworkSymptom) Setup() {
	log.Debug("Setting up ShittyNetworkSymptom: Enabling firewall")

	ports := ParsePorts(strings.Join(s.TargetPorts, ","))
	targetIPv4, targetIPv6 := parseAddrs(strings.Join(append(s.TargetIps, s.TargetIps6...), ","))

	s.config = throttler.Config{
		Device:           s.Device,
		Latency:          s.Latency,
		TargetBandwidth:  s.TargetBandwidth,
		DefaultBandwidth: s.DefaultBandwidth,
		PacketLoss:       s.PacketLoss,
		TargetIps:        targetIPv4,
		TargetIps6:       targetIPv6,
		TargetPorts:      ports,
		TargetProtos:     s.TargetProtos,
		DryRun:           false,
	}

	supressOutput(func() {
		throttler.Run(&s.config)
	})

}