#lang syndicate
;; Demonstration stack configuration for various hosts.

(require racket/match)
(require (only-in mzlib/os gethostname))
(require (only-in racket/string string-split))
(require "configuration.rkt")

(spawn
 (match (gethostname)
   [other ;; assume a private network
    (define-values (interface mkaddr me gw)
      (match (car (string-split other "."))
        ["skip" (values "en0" (lambda (v) (bytes 192 168 2 v)) 222 254)]
        ["leap" (values "wlp4s0" ;; wtf
                        (lambda (v) (bytes 192 168 2 v))
                        222
                        254)]
        [_ (values "wlan0" (lambda (v) (bytes 192 168 2 v)) 222 254)]))
    (assert (gateway-route (bytes 0 0 0 0) 0 (mkaddr gw) interface))
    (assert (host-route (mkaddr me) 24 interface))]))
