diff --git a/service/proxy/lib/proxy.ex b/service/proxy/lib/proxy.ex index 9440e03..4c25116 100644 --- a/service/proxy/lib/proxy.ex +++ b/service/proxy/lib/proxy.ex @@ -1,6 +1,11 @@ defmodule Proxy do + use Task, restart: :permanent require Logger + def start_link(port) do + Task.start_link(__MODULE__, :accept, [port]) + end + def accept(port) do {:ok, socket} = :gen_tcp.listen(port, [:binary, packet: :raw, active: false, reuseaddr: true]) Logger.info("Accepting connections on port #{port}") @@ -50,6 +55,7 @@ defmodule Proxy do # don't allow connections to restricted services service_permissions = Map.get(hosts_acls, host) + if service_permissions != nil and not service_permissions do throw_socks_error( socket, diff --git a/service/proxy/lib/proxy/application.ex b/service/proxy/lib/proxy/application.ex index 048783b..7084fd9 100644 --- a/service/proxy/lib/proxy/application.ex +++ b/service/proxy/lib/proxy/application.ex @@ -4,7 +4,7 @@ defmodule Proxy.Application do children = [ {Task.Supervisor, name: Proxy.TaskSupervisor}, - {Task, fn -> Proxy.accept(port) end}, + {Proxy, port}, Proxy.Scheduler, {Proxy.UserCache, name: Proxy.UserCache}, {MyXQL, username: "proxy", hostname: "db", database: "pod", name: :myxql, pool_size: 8}