Skip to content

Instantly share code, notes, and snippets.

diff --git a/fteproxy/regex2dfa.py b/fteproxy/regex2dfa.py
index 3c65fb1..5b2184d 100644
--- a/fteproxy/regex2dfa.py
+++ b/fteproxy/regex2dfa.py
@@ -1,3 +1,5 @@
+from __future__ import absolute_import
+import regex2dfa as r2d
_regex2dfa = {}
# defining regexes as strings makes them resuable
string http_get = "^GET\ \/([a-zA-Z0-9\.\/]*) HTTP/1\.1\r\n\r\n$"
string http_put = "^PUT\ \/([a-zA-Z0-9\.\/]*) HTTP/1\.1\r\n\r\n$"
string http_200 = "HTTP/1.1 200 OK..."
string http_400 = "HTTP/1.1 400 Bad Request..."
string http_404 = "HTTP/1.1 404 File Not Found..."
string dot_plus = ".+"
# our connection model.
# we've introduced the new "error" transition.
var http_get_regex = "^GET\ \/([a-zA-Z0-9\.\/]*) HTTP/1\.1\r\n\r\n$"
var http_put_regex = "^PUT\ \/([a-zA-Z0-9\.\/]*) HTTP/1\.1\r\n\r\n$";
var http_200_regex = "HTTP/1.1 200 OK...";
var http_400_regex = "HTTP/1.1 400 Bad Request...";
var http_404_regex = "HTTP/1.1 404 File Not Found...";
connection(tcp, 80):
start upstream NULL 1.0
upstream downstream http_request_get 0.5
upstream downstream http_request_put 0.5
connection(tcp, 80):
start http_get_state http_get 0.5
start http_get_state_err http_get_err
start http_put_state http_put 0.5
start http_put_state_err http_put_err
http_put_state ... ... 1.0
http_put_state_err ... ...
http_get_state http_ok_state http_ok 1.0
http_get_state_err http_mal_state http_mal
connection(tcp, 8080):
start client http_get 1.0
client server http_ok 1.0
server end NULL 1.0
action http_get:
server io.gets("GET / HTTP/1.0\r\n\r\n")
action http_ok:
server io.puts("HTTP/1.1 301 Moved Permanently\r\nContent-Type: text/html; charset=iso-8859-1\r\nLocation: myserver\r\nServer: Apache/2.4.7 (Ubuntu)\r\nContent-Length: 335\r\nConnection: Close\r\n\r\n<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">\r\n<html><head>\r\n<title>301 Moved Permanently</title>\r\n</head><body>\r\n<h1>Moved Permanently</h1>\r\n<p>The document has moved <a href="https://kpdyer.com/">here</a>.</p>\r\n<hr>\r\n<address>Apache/2.4.7 (Ubuntu) Server at ip-10-252-25-132.us-west-2.compute.internal Port 80</address>\r\n</body></html>\r\n")
# model = http_blocking
connection(tcp, 80):
start upstream NULL 1.0
upstream downstream http_request_get 0.5
upstream downstream http_request_post 0.5
downstream end http_response 1.0
action http_request_get:
http_get_regex = "^GET\ \/([a-zA-Z0-9\.\/]*) HTTP/1\.1\r\n\r\n$"
client fte.send(http_get_regex, 128)
connection(tcp, 80):
start upstream NULL 1.0
upstream downstream http_request 1.0
downstream end http_response 1.0
action http_request:
client fte.send("^GET\ \/([a-zA-Z0-9\.\/]*) HTTP/1\.1\r\n\r\n$", 128)
action http_response:
server fte.send("^HTTP/1\.1\ 200 OK\r\nContent-Type:\ ([a-zA-Z0-9]+)\r\n\r\n\C*$", 128)
connection(tcp, 80):
start upstream NULL 1.0
upstream downstream http_request 1.0
downstream end http_response 1.0
action http_request:
client fte.send("^GET\ \/([a-zA-Z0-9\.\/]*) HTTP/1\.1\r\n\r\n$", 128)
action http_response:
success:

Keybase proof

I hereby claim:

  • I am kpdyer on github.
  • I am kpdyer (https://keybase.io/kpdyer) on keybase.
  • I have a public key whose fingerprint is 5900 F098 C290 F0AA A042 F4B0 6B89 8EE1 8FBA 6390

To claim this, I am signing this object: