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,22 +13,22 @@ defmodule Tres.Utils do
|
|||
end
|
||||
|
||||
def start_openflow_listener do
|
||||
max_connections = get_config(:max_connections, @default_max_connections)
|
||||
num_acceptors = get_config(:num_acceptors, @default_num_acceptors)
|
||||
port = get_config(:port, @default_openflow_port)
|
||||
options = [max_connections: max_connections, num_acceptors: num_acceptors, port: port]
|
||||
:ranch.start_listener(Tres, :ranch_tcp, options, @connection_manager, [])
|
||||
:ranch.start_listener(
|
||||
_ref = Tres,
|
||||
_trasport = :ranch_tcp,
|
||||
_transport_opts = transport_options(),
|
||||
_protocol = @connection_manager,
|
||||
_protocol_opts = []
|
||||
)
|
||||
end
|
||||
|
||||
def send_message(message, socket, transport) do
|
||||
try do
|
||||
packet = Openflow.to_binary(message)
|
||||
transport.send(socket, packet)
|
||||
catch
|
||||
_class, _reason ->
|
||||
error("[#{__MODULE__}] Unencodable error: #{inspect(message)}")
|
||||
end
|
||||
end
|
||||
|
||||
def is_multipart?(message) do
|
||||
message.__struct__
|
||||
|
|
@ -54,7 +54,32 @@ defmodule Tres.Utils do
|
|||
end
|
||||
|
||||
# private functions
|
||||
|
||||
defp get_config(item, default) do
|
||||
Application.get_env(:tres, item, default)
|
||||
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
|
||||
|
|
|
|||
2
mix.exs
2
mix.exs
|
|
@ -22,7 +22,7 @@ defmodule Tres.Mixfile do
|
|||
# Run "mix help deps" to learn about dependencies.
|
||||
defp deps do
|
||||
[
|
||||
{:ranch, "~> 1.4.0"},
|
||||
{:ranch, "~> 1.6.0"},
|
||||
{:eovsdb, github: "shun159/eovsdb", branch: "master"},
|
||||
{:jsone, github: "sile/jsone", tag: "1.4.6", override: true},
|
||||
{: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"},
|
||||
"jsone": {:git, "https://github.com/sile/jsone.git", "b23d312a5ed051ea7ad0989a9f2cb1a9c3f9a502", [tag: "1.4.6"]},
|
||||
"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"]},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue