Fix net/dns contracts

This commit is contained in:
Asumu Takikawa 2013-03-01 00:48:11 -05:00
parent 9d08d69d07
commit 14c77c39d2

View File

@ -35,12 +35,17 @@
val)]) val)])
(and matches (and matches
(= (length matches) 5) (= (length matches) 5)
;; check that each octet field is an octet
(andmap byte? (map string->number (cdr matches)))
;; leading zeroes lead to query errors
(not (ormap has-leading-zeroes? matches)))))) (not (ormap has-leading-zeroes? matches))))))
(module+ test (module+ test
(check-true (ip-address-string? "8.8.8.8")) (check-true (ip-address-string? "8.8.8.8"))
(check-true (ip-address-string? "80.8.800.8")) (check-true (ip-address-string? "12.81.255.109"))
(check-true (ip-address-string? "80.8.800.0")) (check-true (ip-address-string? "192.168.0.1"))
(check-false (ip-address-string? "80.8.800.8"))
(check-false (ip-address-string? "80.8.800.0"))
(check-false (ip-address-string? "080.8.800.8")) (check-false (ip-address-string? "080.8.800.8"))
(check-false (ip-address-string? "vas8.8.800.8")) (check-false (ip-address-string? "vas8.8.800.8"))
(check-false (ip-address-string? "80.8.128.8dd")) (check-false (ip-address-string? "80.8.128.8dd"))