Update ranch 1.4.0 to 1.6.0
This commit is contained in:
parent
82867b2ac4
commit
83c2ce048a
4 changed files with 39 additions and 14 deletions
BIN
bin/enum_gen
BIN
bin/enum_gen
Binary file not shown.
|
|
@ -13,21 +13,21 @@ defmodule Tres.Utils do
|
||||||
end
|
end
|
||||||
|
|
||||||
def start_openflow_listener do
|
def start_openflow_listener do
|
||||||
max_connections = get_config(:max_connections, @default_max_connections)
|
:ranch.start_listener(
|
||||||
num_acceptors = get_config(:num_acceptors, @default_num_acceptors)
|
_ref = Tres,
|
||||||
port = get_config(:port, @default_openflow_port)
|
_trasport = :ranch_tcp,
|
||||||
options = [max_connections: max_connections, num_acceptors: num_acceptors, port: port]
|
_transport_opts = transport_options(),
|
||||||
:ranch.start_listener(Tres, :ranch_tcp, options, @connection_manager, [])
|
_protocol = @connection_manager,
|
||||||
|
_protocol_opts = []
|
||||||
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
def send_message(message, socket, transport) do
|
def send_message(message, socket, transport) do
|
||||||
try do
|
packet = Openflow.to_binary(message)
|
||||||
packet = Openflow.to_binary(message)
|
transport.send(socket, packet)
|
||||||
transport.send(socket, packet)
|
catch
|
||||||
catch
|
_class, _reason ->
|
||||||
_class, _reason ->
|
error("[#{__MODULE__}] Unencodable error: #{inspect(message)}")
|
||||||
error("[#{__MODULE__}] Unencodable error: #{inspect(message)}")
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_multipart?(message) do
|
def is_multipart?(message) do
|
||||||
|
|
@ -54,7 +54,32 @@ defmodule Tres.Utils do
|
||||||
end
|
end
|
||||||
|
|
||||||
# private functions
|
# private functions
|
||||||
|
|
||||||
defp get_config(item, default) do
|
defp get_config(item, default) do
|
||||||
Application.get_env(:tres, item, default)
|
Application.get_env(:tres, item, default)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
defp transport_options do
|
||||||
|
%{
|
||||||
|
max_connections: max_connections(),
|
||||||
|
num_acceptors: num_acceptors(),
|
||||||
|
logger: :logger,
|
||||||
|
socket_opts: socket_opts()
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
|
defp socket_opts do
|
||||||
|
[
|
||||||
|
port: port()
|
||||||
|
]
|
||||||
|
end
|
||||||
|
|
||||||
|
defp port,
|
||||||
|
do: get_config(:port, @default_openflow_port)
|
||||||
|
|
||||||
|
defp max_connections,
|
||||||
|
do: get_config(:max_connections, @default_max_connections)
|
||||||
|
|
||||||
|
defp num_acceptors,
|
||||||
|
do: get_config(:num_acceptors, @default_num_acceptors)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
2
mix.exs
2
mix.exs
|
|
@ -22,7 +22,7 @@ defmodule Tres.Mixfile do
|
||||||
# Run "mix help deps" to learn about dependencies.
|
# Run "mix help deps" to learn about dependencies.
|
||||||
defp deps do
|
defp deps do
|
||||||
[
|
[
|
||||||
{:ranch, "~> 1.4.0"},
|
{:ranch, "~> 1.6.0"},
|
||||||
{:eovsdb, github: "shun159/eovsdb", branch: "master"},
|
{:eovsdb, github: "shun159/eovsdb", branch: "master"},
|
||||||
{:jsone, github: "sile/jsone", tag: "1.4.6", override: true},
|
{:jsone, github: "sile/jsone", tag: "1.4.6", override: true},
|
||||||
{:epcap, github: "msantos/epcap", branch: "master", only: :test}
|
{:epcap, github: "msantos/epcap", branch: "master", only: :test}
|
||||||
|
|
|
||||||
2
mix.lock
2
mix.lock
|
|
@ -7,6 +7,6 @@
|
||||||
"gen_state_machine": {:hex, :gen_state_machine, "2.0.1", "85efd5a0376929c3a4246dd943e17564a2908c7ddd7acd242d84594e785d83f8", [], [], "hexpm"},
|
"gen_state_machine": {:hex, :gen_state_machine, "2.0.1", "85efd5a0376929c3a4246dd943e17564a2908c7ddd7acd242d84594e785d83f8", [], [], "hexpm"},
|
||||||
"jsone": {:git, "https://github.com/sile/jsone.git", "b23d312a5ed051ea7ad0989a9f2cb1a9c3f9a502", [tag: "1.4.6"]},
|
"jsone": {:git, "https://github.com/sile/jsone.git", "b23d312a5ed051ea7ad0989a9f2cb1a9c3f9a502", [tag: "1.4.6"]},
|
||||||
"pkt": {:git, "https://github.com/msantos/pkt.git", "ff0e9a7d28cdae941bce935602cd252cad1ea296", [branch: "master"]},
|
"pkt": {:git, "https://github.com/msantos/pkt.git", "ff0e9a7d28cdae941bce935602cd252cad1ea296", [branch: "master"]},
|
||||||
"ranch": {:hex, :ranch, "1.4.0", "10272f95da79340fa7e8774ba7930b901713d272905d0012b06ca6d994f8826b", [:rebar3], [], "hexpm"},
|
"ranch": {:hex, :ranch, "1.6.0", "92ac674645ec5dd23c6f0aeb9fff0aae1dd4e94a0af8407ff4d14f750a4cd7cf", [:rebar3], [], "hexpm"},
|
||||||
"uuid": {:git, "https://github.com/avtobiff/erlang-uuid.git", "585c2474afb4a597ae8c8bf6d21e5a9c73f18e0b", [tag: "v0.5.0"]},
|
"uuid": {:git, "https://github.com/avtobiff/erlang-uuid.git", "585c2474afb4a597ae8c8bf6d21e5a9c73f18e0b", [tag: "v0.5.0"]},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue