Skip to content
This repository was archived by the owner on Feb 6, 2024. It is now read-only.

Commit 974cddf

Browse files
committed
handler: use surveyor
1 parent c336281 commit 974cddf

File tree

4 files changed

+24
-31
lines changed

4 files changed

+24
-31
lines changed

infra/default.nix

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ rec
1313
tar -xvf ${pkgs.sources.dynamodb}
1414
'';
1515

16-
test = pkgs.runCommand "tests" { buildInputs = [ pkgs.jre pkgs.curl pkgs.netcat pkgs.strace ]; }
16+
test = pkgs.runCommand "tests" { buildInputs = [ pkgs.jre pkgs.curl pkgs.netcat pkgs.strace pkgs.dnsmasq pkgs.dnsutils ]; }
1717
''
1818
1919
java -Djava.library.path=${dynamoJar}/DynamoDBLocal_lib -jar ${dynamoJar}/DynamoDBLocal.jar -sharedDb -port 8000 &
@@ -24,28 +24,35 @@ rec
2424
done
2525
sleep 2
2626
27+
NIX_REDIRECTS=/etc/hosts=${hostsFile} \
28+
LD_PRELOAD="${pkgs.libredirect}/lib/libredirect.so" \
29+
dnsmasq -p 8053 &
2730
28-
ls ${pkgs.otherport}/lib
29-
30-
strace -f -e trace=network -s 10000 curl dynamodb.us-east-1.coo
31+
while ! nc -z 127.0.0.1 8053; do
32+
echo waiting for dnsmasq
33+
sleep 1
34+
done
35+
sleep 2
3136
32-
exit 1
37+
SRV_MAP="127.0.0.1:53:127.0.0.1:8053 127.0.0.1:80:127.0.0.1:8000" \
38+
LD_PRELOAD="${pkgs.surveyor}/lib/surveyor.so" \
39+
strace -f -e trace=network nslookup -port=8053 dynamodb.us-east-1.amazonaws.com
3340
3441
NIX_REDIRECTS=/etc/hosts=${hostsFile} \
35-
OLD_PORT=80 NEW_PORT=8000 \
36-
LD_PRELOAD="${pkgs.libredirect}/lib/libredirect.so ${pkgs.otherport}/lib/otherport.so" \
37-
AWS_DEFAULT_REGION=us-east-1 \
38-
AWS_ACCESS_KEY_ID=dummy \
39-
AWS_SECRET_ACCESS_KEY=dummy \
40-
strace curl dynamodb.us-east-1.amazonaws.com
42+
SRV_MAP="127.0.0.1:80:127.0.0.1:8000" \
43+
LD_PRELOAD="${pkgs.libredirect}/lib/libredirect.so ${pkgs.surveyor}/lib/surveyor.so" \
44+
curl dynamodb.us-east-1.amazonaws.com
45+
#strace -f -e trace=file curl dynamodb.us-east-1.amazonaws.com
46+
47+
exit 1
4148
4249
NIX_REDIRECTS=/etc/hosts=${hostsFile} \
43-
OLD_PORT=80 NEW_PORT=8000 \
44-
LD_PRELOAD="${pkgs.libredirect}/lib/libredirect.so ${pkgs.otherport}/lib/otherport.so" \
50+
SRV_MAP="127.0.0.1:80:127.0.0.1:8000" \
51+
LD_PRELOAD="${pkgs.libredirect}/lib/libredirect.so ${pkgs.surveyor}/lib/surveyor.so" \
4552
AWS_DEFAULT_REGION=us-east-1 \
4653
AWS_ACCESS_KEY_ID=dummy \
4754
AWS_SECRET_ACCESS_KEY=dummy \
48-
${handler}/bin/server &
55+
strace -f -e trace=network ${handler}/bin/server &
4956
5057
while ! nc -z 127.0.0.1 8080; do
5158
echo waiting for warp

infra/nix/default.nix

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ with rec
33
{ sources = import ./sources.nix;
44
pkgs = import sources.nixpkgs {};
55
wai-lambda = pkgs.callPackage "${sources.wai-lambda}/nix/packages.nix" {};
6+
surveyor = pkgs.callPackage ../surveyor {};
67

78
pkgsStatic =
89
(import "${sources.static-haskell-nix}/survey"
@@ -41,9 +42,6 @@ with rec
4142

4243
pkgs //
4344
{ inherit haskellPackagesStatic haskellPackages sources wai-lambda;
45+
inherit (surveyor) surveyor;
4446
inherit (import sources.niv {}) niv;
45-
otherport = pkgs.stdenv.mkDerivation
46-
{ name = "otherport"; src = sources.otherport;
47-
installPhase = "mkdir -p $out/lib && cp otherport.so $out/lib";
48-
} ;
4947
}

infra/nix/sources.json

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,6 @@
2626
"type": "file",
2727
"sha256": "0hrwxg4igyll40y7l1s0icg55g247fl8cjs4rrcpjf8d7m0bb09j"
2828
},
29-
"otherport": {
30-
"homepage": "",
31-
"url": "https://github.com/FiloSottile/otherport/archive/9d67c3619c457e5f663a789ee7fd29295cac7870.tar.gz",
32-
"owner": "FiloSottile",
33-
"branch": "master",
34-
"url_template": "https://github.com/<owner>/<repo>/archive/<rev>.tar.gz",
35-
"repo": "otherport",
36-
"type": "tarball",
37-
"sha256": "0553mq6wxhd4zvq73r3b1cp3s52anld099bc4pw9ny4mb20hrhm3",
38-
"description": "LD_PRELOAD hack to redirect connections to other ports",
39-
"rev": "9d67c3619c457e5f663a789ee7fd29295cac7870"
40-
},
4129
"static-haskell-nix": {
4230
"homepage": "",
4331
"url": "https://github.com/nh2/static-haskell-nix/archive/9781df8a48eade302d159ce63a7ab0c30247788c.tar.gz",

infra/surveyor/surveyor.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ void _init(void)
9797
{
9898
int res;
9999

100-
fprintf(stderr, "Parsing mapping %d \n", n_mappings);
100+
fprintf(stderr, "Parsing mapping %d \n", i+1);
101101

102102
pch = strtok(mappings_strs[i], ":");
103103
if(pch == NULL){ exit(43); }

0 commit comments

Comments
 (0)