-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathProgram.fs
More file actions
34 lines (29 loc) · 848 Bytes
/
Copy pathProgram.fs
File metadata and controls
34 lines (29 loc) · 848 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
open System
open System.Net
open System.Threading
open Server
[<EntryPoint>]
let main argv =
printfn "F# DNS server"
use tokenSource = new CancellationTokenSource()
Server.listen tokenSource.Token 5300
(fun query ->
async {
do printfn "Questions: %A" query
if query.Questions |> Array.exists (fun q -> q.Domain.EndsWith ".romcyber.com")
then
return
Found [|
{ Domain="www.romcyber.com"
Type=QueryType.A
Class=QueryClass.IN
TTL=TimeSpan.FromMinutes 20.
Ip=IPAddress.Parse "127.0.0.1"
}
|]
else
let ip = IPAddress.Parse "8.8.8.8"
return ForwardTo (ip, 53)
}
) |> Async.RunSynchronously
0 // return an integer exit code