ejabberd-18.01/ 0000755 0002322 0002322 00000000000 13225667423 013641 5 ustar debalance debalance ejabberd-18.01/inetrc 0000644 0002322 0002322 00000000157 13225664356 015055 0 ustar debalance debalance {lookup,["file","native"]}.
{host,{127,0,0,1}, ["localhost","hostalias"]}.
{file, resolv, "/etc/resolv.conf"}.
ejabberd-18.01/lib/ 0000755 0002322 0002322 00000000000 13225664356 014411 5 ustar debalance debalance ejabberd-18.01/lib/ct_formatter.ex 0000644 0002322 0002322 00000010524 13225664356 017442 0 ustar debalance debalance defmodule ExUnit.CTFormatter do
@moduledoc false
use GenEvent
import ExUnit.Formatter, only: [format_time: 2, format_test_failure: 5,
format_test_case_failure: 5]
def init(opts) do
file = File.open! "exunit.log", [:append]
# We do not print filter in log file as exclusion of test with tag
# pending: true is always done
config = %{
file: file,
seed: opts[:seed],
trace: opts[:trace],
colors: Keyword.put_new(opts[:colors], :enabled, false),
width: 80,
tests_counter: 0,
failures_counter: 0,
skipped_counter: 0,
invalids_counter: 0
}
{:ok, config}
end
def handle_event({:suite_started, _opts}, config) do
{:ok, config}
end
def handle_event({:suite_finished, run_us, load_us}, config) do
print_suite(config, run_us, load_us)
File.close config[:file]
:remove_handler
end
def handle_event({:test_started, %ExUnit.Test{} = test}, config) do
if config.tests_counter == 0, do: IO.binwrite config[:file], "== Running #{test.case} ==\n\n"
{:ok, config}
end
def handle_event({:test_finished, %ExUnit.Test{state: nil} = _test}, config) do
IO.binwrite config[:file], "."
{:ok, %{config | tests_counter: config.tests_counter + 1}}
end
def handle_event({:test_finished, %ExUnit.Test{state: {:skip, _}} = _test}, config) do
{:ok, %{config | tests_counter: config.tests_counter + 1,
skipped_counter: config.skipped_counter + 1}}
end
def handle_event({:test_finished, %ExUnit.Test{state: {:invalid, _}} = _test}, config) do
IO.binwrite config[:file], "?"
{:ok, %{config | tests_counter: config.tests_counter + 1,
invalids_counter: config.invalids_counter + 1}}
end
def handle_event({:test_finished, %ExUnit.Test{state: {:failed, failures}} = test}, config) do
formatted = format_test_failure(test, failures, config.failures_counter + 1,
config.width, &formatter(&1, &2, config))
print_failure(formatted, config)
print_logs(test.logs)
{:ok, %{config | tests_counter: config.tests_counter + 1,
failures_counter: config.failures_counter + 1}}
end
def handle_event({:case_started, %ExUnit.TestCase{}}, config) do
{:ok, config}
end
def handle_event({:case_finished, %ExUnit.TestCase{state: nil}}, config) do
{:ok, config}
end
def handle_event({:case_finished, %ExUnit.TestCase{state: {:failed, failures}} = test_case}, config) do
formatted = format_test_case_failure(test_case, failures, config.failures_counter + 1,
config.width, &formatter(&1, &2, config))
print_failure(formatted, config)
{:ok, %{config | failures_counter: config.failures_counter + 1}}
end
## Printing
defp print_suite(config, run_us, load_us) do
IO.binwrite config[:file], "\n\n"
IO.binwrite config[:file], format_time(run_us, load_us)
IO.binwrite config[:file], "\n\n"
# singular/plural
test_pl = pluralize(config.tests_counter, "test", "tests")
failure_pl = pluralize(config.failures_counter, "failure", "failures")
message =
"#{config.tests_counter} #{test_pl}, #{config.failures_counter} #{failure_pl}"
|> if_true(config.skipped_counter > 0, & &1 <> ", #{config.skipped_counter} skipped")
|> if_true(config.invalids_counter > 0, & &1 <> ", #{config.invalids_counter} invalid")
cond do
config.failures_counter > 0 -> IO.binwrite config[:file], message
config.invalids_counter > 0 -> IO.binwrite config[:file], message
true -> IO.binwrite config[:file], message
end
IO.binwrite config[:file], "\nRandomized with seed #{config.seed}\n\n\n\n"
end
defp if_true(value, false, _fun), do: value
defp if_true(value, true, fun), do: fun.(value)
defp print_failure(formatted, config) do
IO.binwrite config[:file], "\n"
IO.binwrite config[:file], formatted
IO.binwrite config[:file], "\n"
end
defp formatter(_, msg, _config),
do: msg
defp pluralize(1, singular, _plural), do: singular
defp pluralize(_, _singular, plural), do: plural
defp print_logs(""), do: nil
defp print_logs(output) do
indent = "\n "
output = String.replace(output, "\n", indent)
IO.puts([" The following output was logged:", indent | output])
end
end
ejabberd-18.01/lib/mix/ 0000755 0002322 0002322 00000000000 13225664356 015206 5 ustar debalance debalance ejabberd-18.01/lib/mix/tasks/ 0000755 0002322 0002322 00000000000 13225664356 016333 5 ustar debalance debalance ejabberd-18.01/lib/mix/tasks/deps.tree.ex 0000644 0002322 0002322 00000005746 13225664356 020576 0 ustar debalance debalance defmodule Mix.Tasks.Ejabberd.Deps.Tree do
use Mix.Task
alias Ejabberd.Config.EjabberdModule
@shortdoc "Lists all ejabberd modules and their dependencies"
@moduledoc """
Lists all ejabberd modules and their dependencies.
The project must have ejabberd as a dependency.
"""
def run(_argv) do
# First we need to start manually the store to be available
# during the compilation of the config file.
Ejabberd.Config.Store.start_link
Ejabberd.Config.init(:ejabberd_config.get_ejabberd_config_path())
Mix.shell.info "ejabberd modules"
Ejabberd.Config.Store.get(:modules)
|> Enum.reverse # Because of how mods are stored inside the store
|> format_mods
|> Mix.shell.info
end
defp format_mods(mods) when is_list(mods) do
deps_tree = build_dependency_tree(mods)
mods_used_as_dependency = get_mods_used_as_dependency(deps_tree)
keep_only_mods_not_used_as_dep(deps_tree, mods_used_as_dependency)
|> format_mods_into_string
end
defp build_dependency_tree(mods) do
Enum.map mods, fn %EjabberdModule{module: mod, attrs: attrs} ->
deps = attrs[:dependency]
build_dependency_tree(mods, mod, deps)
end
end
defp build_dependency_tree(mods, mod, []), do: %{module: mod, dependency: []}
defp build_dependency_tree(mods, mod, deps) when is_list(deps) do
dependencies = Enum.map deps, fn dep ->
dep_deps = get_dependencies_of_mod(mods, dep)
build_dependency_tree(mods, dep, dep_deps)
end
%{module: mod, dependency: dependencies}
end
defp get_mods_used_as_dependency(mods) when is_list(mods) do
Enum.reduce mods, [], fn(mod, acc) ->
case mod do
%{dependency: []} -> acc
%{dependency: deps} -> get_mod_names(deps) ++ acc
end
end
end
defp get_mod_names([]), do: []
defp get_mod_names(mods) when is_list(mods), do: Enum.map(mods, &get_mod_names/1) |> List.flatten
defp get_mod_names(%{module: mod, dependency: deps}), do: [mod | get_mod_names(deps)]
defp keep_only_mods_not_used_as_dep(mods, mods_used_as_dep) do
Enum.filter mods, fn %{module: mod} ->
not mod in mods_used_as_dep
end
end
defp get_dependencies_of_mod(deps, mod_name) do
Enum.find(deps, &(Map.get(&1, :module) == mod_name))
|> Map.get(:attrs)
|> Keyword.get(:dependency)
end
defp format_mods_into_string(mods), do: format_mods_into_string(mods, 0)
defp format_mods_into_string([], _indentation), do: ""
defp format_mods_into_string(mods, indentation) when is_list(mods) do
Enum.reduce mods, "", fn(mod, acc) ->
acc <> format_mods_into_string(mod, indentation)
end
end
defp format_mods_into_string(%{module: mod, dependency: deps}, 0) do
"\n├── #{mod}" <> format_mods_into_string(deps, 2)
end
defp format_mods_into_string(%{module: mod, dependency: deps}, indentation) do
spaces = Enum.reduce 0..indentation, "", fn(_, acc) -> " " <> acc end
"\n│#{spaces}└── #{mod}" <> format_mods_into_string(deps, indentation + 4)
end
end
ejabberd-18.01/lib/ejabberd/ 0000755 0002322 0002322 00000000000 13225664356 016147 5 ustar debalance debalance ejabberd-18.01/lib/ejabberd/module.ex 0000644 0002322 0002322 00000000572 13225664356 017776 0 ustar debalance debalance defmodule Ejabberd.Module do
defmacro __using__(opts) do
logger_enabled = Keyword.get(opts, :logger, true)
quote do
@behaviour :gen_mod
import Ejabberd.Module
unquote(if logger_enabled do
quote do: import Ejabberd.Logger
end)
end
end
# gen_mod callbacks
def depends(_host, _opts), do: []
def mod_opt_type(_), do: []
end
ejabberd-18.01/lib/ejabberd/config_util.ex 0000644 0002322 0002322 00000000652 13225664356 021012 0 ustar debalance debalance defmodule Ejabberd.ConfigUtil do
@moduledoc """
Module containing utility functions for
the config file.
"""
@doc """
Returns true when the config file is based on elixir.
"""
@spec is_elixir_config(list) :: boolean
def is_elixir_config(filename) when is_list(filename) do
is_elixir_config(to_string(filename))
end
def is_elixir_config(filename) do
String.ends_with?(filename, "exs")
end
end
ejabberd-18.01/lib/ejabberd/config/ 0000755 0002322 0002322 00000000000 13225664356 017414 5 ustar debalance debalance ejabberd-18.01/lib/ejabberd/config/validator/ 0000755 0002322 0002322 00000000000 13225664356 021401 5 ustar debalance debalance ejabberd-18.01/lib/ejabberd/config/validator/validation.ex 0000644 0002322 0002322 00000002437 13225664356 024077 0 ustar debalance debalance defmodule Ejabberd.Config.Validation do
@moduledoc """
Module used to validate a list of modules.
"""
@type mod_validation :: {[EjabberdModule.t], EjabberdModule.t, map}
@type mod_validation_result :: {:ok, EjabberdModule.t} | {:error, EjabberdModule.t, map}
alias Ejabberd.Config.EjabberdModule
alias Ejabberd.Config.Attr
alias Ejabberd.Config.Validator
alias Ejabberd.Config.ValidatorUtility
@doc """
Given a module or a list of modules it runs validators on them
and returns {:ok, mod} or {:error, mod, errors}, for each
of them.
"""
@spec validate([EjabberdModule.t] | EjabberdModule.t) :: [mod_validation_result]
def validate(modules) when is_list(modules), do: Enum.map(modules, &do_validate(modules, &1))
def validate(module), do: validate([module])
# Private API
@spec do_validate([EjabberdModule.t], EjabberdModule.t) :: mod_validation_result
defp do_validate(modules, mod) do
{modules, mod, %{}}
|> Validator.Attrs.validate
|> Validator.Dependencies.validate
|> resolve_validation_result
end
@spec resolve_validation_result(mod_validation) :: mod_validation_result
defp resolve_validation_result({_modules, mod, errors}) do
case errors do
err when err == %{} -> {:ok, mod}
err -> {:error, mod, err}
end
end
end
ejabberd-18.01/lib/ejabberd/config/validator/validator_dependencies.ex 0000644 0002322 0002322 00000001704 13225664356 026434 0 ustar debalance debalance defmodule Ejabberd.Config.Validator.Dependencies do
@moduledoc """
Validator module used to validate dependencies specified
with the @dependency annotation.
"""
# TODO: Duplicated from validator.ex !!!
@type mod_validation :: {[EjabberdModule.t], EjabberdModule.t, map}
import Ejabberd.Config.ValidatorUtility
@doc """
Given a module (with the form used for validation)
it checks if the @dependency annotation is respected and
returns the validation tuple with the errors updated, if found.
"""
@spec validate(mod_validation) :: mod_validation
def validate({modules, mod, errors}) do
module_names = extract_module_names(modules)
dependencies = mod.attrs[:dependency]
errors = Enum.reduce dependencies, errors, fn(req_module, err) ->
case req_module in module_names do
true -> err
false -> put_error(err, :dependency, {req_module, :not_found})
end
end
{modules, mod, errors}
end
end
ejabberd-18.01/lib/ejabberd/config/validator/validator_attrs.ex 0000644 0002322 0002322 00000001501 13225664356 025136 0 ustar debalance debalance defmodule Ejabberd.Config.Validator.Attrs do
@moduledoc """
Validator module used to validate attributes.
"""
# TODO: Duplicated from validator.ex !!!
@type mod_validation :: {[EjabberdModule.t], EjabberdModule.t, map}
import Ejabberd.Config.ValidatorUtility
alias Ejabberd.Config.Attr
@doc """
Given a module (with the form used for validation)
it runs Attr.validate/1 on each attribute and
returns the validation tuple with the errors updated, if found.
"""
@spec validate(mod_validation) :: mod_validation
def validate({modules, mod, errors}) do
errors = Enum.reduce mod.attrs, errors, fn(attr, err) ->
case Attr.validate(attr) do
{:ok, attr} -> err
{:error, attr, cause} -> put_error(err, :attribute, {attr, cause})
end
end
{modules, mod, errors}
end
end
ejabberd-18.01/lib/ejabberd/config/validator/validator_utility.ex 0000644 0002322 0002322 00000001555 13225664356 025515 0 ustar debalance debalance defmodule Ejabberd.Config.ValidatorUtility do
@moduledoc """
Module used as a base validator for validation modules.
Imports utility functions for working with validation structures.
"""
alias Ejabberd.Config.EjabberdModule
@doc """
Inserts an error inside the errors collection, for the given key.
If the key doesn't exists then it creates an empty collection
and inserts the value passed.
"""
@spec put_error(map, atom, any) :: map
def put_error(errors, key, val) do
Map.update errors, key, [val], fn coll ->
[val | coll]
end
end
@doc """
Given a list of modules it extracts and returns a list
of the module names (which are Elixir.Module).
"""
@spec extract_module_names(EjabberdModule.t) :: [atom]
def extract_module_names(modules) when is_list(modules) do
modules
|> Enum.map(&Map.get(&1, :module))
end
end
ejabberd-18.01/lib/ejabberd/config/ejabberd_hook.ex 0000644 0002322 0002322 00000001043 13225664356 022526 0 ustar debalance debalance defmodule Ejabberd.Config.EjabberdHook do
@moduledoc """
Module containing functions for manipulating
ejabberd hooks.
"""
defstruct hook: nil, opts: [], fun: nil
alias Ejabberd.Config.EjabberdHook
@type t :: %EjabberdHook{}
@doc """
Register a hook to ejabberd.
"""
@spec start(EjabberdHook.t) :: none
def start(%EjabberdHook{hook: hook, opts: opts, fun: fun}) do
host = Keyword.get(opts, :host, :global)
priority = Keyword.get(opts, :priority, 50)
:ejabberd_hooks.add(hook, host, fun, priority)
end
end
ejabberd-18.01/lib/ejabberd/config/logger/ 0000755 0002322 0002322 00000000000 13225664356 020673 5 ustar debalance debalance ejabberd-18.01/lib/ejabberd/config/logger/ejabberd_logger.ex 0000644 0002322 0002322 00000002475 13225664356 024336 0 ustar debalance debalance defmodule Ejabberd.Config.EjabberdLogger do
@moduledoc """
Module used to log validation errors given validated modules
given validated modules.
"""
alias Ejabberd.Config.EjabberdModule
@doc """
Given a list of modules validated, in the form of {:ok, mod} or
{:error, mod, errors}, it logs to the user the errors found.
"""
@spec log_errors([EjabberdModule.t]) :: [EjabberdModule.t]
def log_errors(modules_validated) when is_list(modules_validated) do
Enum.each modules_validated, &do_log_errors/1
modules_validated
end
defp do_log_errors({:ok, _mod}), do: nil
defp do_log_errors({:error, _mod, errors}), do: Enum.each errors, &do_log_errors/1
defp do_log_errors({:attribute, errors}), do: Enum.each errors, &log_attribute_error/1
defp do_log_errors({:dependency, errors}), do: Enum.each errors, &log_dependency_error/1
defp log_attribute_error({{attr_name, val}, :attr_not_supported}), do:
IO.puts "[ WARN ] Annotation @#{attr_name} is not supported."
defp log_attribute_error({{attr_name, val}, :type_not_supported}), do:
IO.puts "[ WARN ] Annotation @#{attr_name} with value #{inspect val} is not supported (type mismatch)."
defp log_dependency_error({module, :not_found}), do:
IO.puts "[ WARN ] Module #{inspect module} was not found, but is required as a dependency."
end
ejabberd-18.01/lib/ejabberd/config/attr.ex 0000644 0002322 0002322 00000010056 13225664356 020726 0 ustar debalance debalance defmodule Ejabberd.Config.Attr do
@moduledoc """
Module used to work with the attributes parsed from
an elixir block (do...end).
Contains functions for extracting attrs from a block
and validation.
"""
@type attr :: {atom(), any()}
@attr_supported [
active:
[type: :boolean, default: true],
git:
[type: :string, default: ""],
name:
[type: :string, default: ""],
opts:
[type: :list, default: []],
dependency:
[type: :list, default: []]
]
@doc """
Takes a block with annotations and extracts the list
of attributes.
"""
@spec extract_attrs_from_block_with_defaults(any()) :: [attr]
def extract_attrs_from_block_with_defaults(block) do
block
|> extract_attrs_from_block
|> put_into_list_if_not_already
|> insert_default_attrs_if_missing
end
@doc """
Takes an attribute or a list of attrs and validate them.
Returns a {:ok, attr} or {:error, attr, cause} for each of the attributes.
"""
@spec validate([attr]) :: [{:ok, attr}] | [{:error, attr, atom()}]
def validate(attrs) when is_list(attrs), do: Enum.map(attrs, &valid_attr?/1)
def validate(attr), do: validate([attr]) |> List.first
@doc """
Returns the type of an attribute, given its name.
"""
@spec get_type_for_attr(atom()) :: atom()
def get_type_for_attr(attr_name) do
@attr_supported
|> Keyword.get(attr_name)
|> Keyword.get(:type)
end
@doc """
Returns the default value for an attribute, given its name.
"""
@spec get_default_for_attr(atom()) :: any()
def get_default_for_attr(attr_name) do
@attr_supported
|> Keyword.get(attr_name)
|> Keyword.get(:default)
end
# Private API
# Given an elixir block (do...end) returns a list with the annotations
# or a single annotation.
@spec extract_attrs_from_block(any()) :: [attr] | attr
defp extract_attrs_from_block({:__block__, [], attrs}), do: Enum.map(attrs, &extract_attrs_from_block/1)
defp extract_attrs_from_block({:@, _, [attrs]}), do: extract_attrs_from_block(attrs)
defp extract_attrs_from_block({attr_name, _, [value]}), do: {attr_name, value}
defp extract_attrs_from_block(nil), do: []
# In case extract_attrs_from_block returns a single attribute,
# then put it into a list. (Ensures attrs are always into a list).
@spec put_into_list_if_not_already([attr] | attr) :: [attr]
defp put_into_list_if_not_already(attrs) when is_list(attrs), do: attrs
defp put_into_list_if_not_already(attr), do: [attr]
# Given a list of attributes, it inserts the missing attribute with their
# default value.
@spec insert_default_attrs_if_missing([attr]) :: [attr]
defp insert_default_attrs_if_missing(attrs) do
Enum.reduce @attr_supported, attrs, fn({attr_name, _}, acc) ->
case Keyword.has_key?(acc, attr_name) do
true -> acc
false -> Keyword.put(acc, attr_name, get_default_for_attr(attr_name))
end
end
end
# Given an attribute, validates it and return a tuple with
# {:ok, attr} or {:error, attr, cause}
@spec valid_attr?(attr) :: {:ok, attr} | {:error, attr, atom()}
defp valid_attr?({attr_name, param} = attr) do
case Keyword.get(@attr_supported, attr_name) do
nil -> {:error, attr, :attr_not_supported}
[{:type, param_type} | _] -> case is_of_type?(param, param_type) do
true -> {:ok, attr}
false -> {:error, attr, :type_not_supported}
end
end
end
# Given an attribute value and a type, it returns a true
# if the value its of the type specified, false otherwise.
# Usefoul for checking if an attr value respects the type
# specified for the annotation.
@spec is_of_type?(any(), atom()) :: boolean()
defp is_of_type?(param, type) when type == :boolean and is_boolean(param), do: true
defp is_of_type?(param, type) when type == :string and is_bitstring(param), do: true
defp is_of_type?(param, type) when type == :list and is_list(param), do: true
defp is_of_type?(param, type) when type == :atom and is_atom(param), do: true
defp is_of_type?(_param, type) when type == :any, do: true
defp is_of_type?(_, _), do: false
end
ejabberd-18.01/lib/ejabberd/config/config.ex 0000644 0002322 0002322 00000007445 13225664356 021231 0 ustar debalance debalance defmodule Ejabberd.Config do
@moduledoc """
Base module for configuration file.
Imports macros for the config DSL and contains functions
for working/starting the configuration parsed.
"""
alias Ejabberd.Config.EjabberdModule
alias Ejabberd.Config.Attr
alias Ejabberd.Config.EjabberdLogger
defmacro __using__(_opts) do
quote do
import Ejabberd.Config, only: :macros
import Ejabberd.Logger
@before_compile Ejabberd.Config
end
end
# Validate the modules parsed and log validation errors at compile time.
# Could be also possible to interrupt the compilation&execution by throwing
# an exception if necessary.
def __before_compile__(_env) do
get_modules_parsed_in_order
|> EjabberdModule.validate
|> EjabberdLogger.log_errors
end
@doc """
Given the path of the config file, it evaluates it.
"""
def init(file_path, force \\ false) do
init_already_executed = Ejabberd.Config.Store.get(:module_name) != []
case force do
true ->
Ejabberd.Config.Store.stop
Ejabberd.Config.Store.start_link
do_init(file_path)
false ->
if not init_already_executed, do: do_init(file_path)
end
end
@doc """
Returns a list with all the opts, formatted for ejabberd.
"""
def get_ejabberd_opts do
get_general_opts
|> Dict.put(:modules, get_modules_parsed_in_order())
|> Dict.put(:listeners, get_listeners_parsed_in_order())
|> Ejabberd.Config.OptsFormatter.format_opts_for_ejabberd
end
@doc """
Register the hooks defined inside the elixir config file.
"""
def start_hooks do
get_hooks_parsed_in_order()
|> Enum.each(&Ejabberd.Config.EjabberdHook.start/1)
end
###
### MACROS
###
defmacro listen(module, do: block) do
attrs = Attr.extract_attrs_from_block_with_defaults(block)
quote do
Ejabberd.Config.Store.put(:listeners, %EjabberdModule{
module: unquote(module),
attrs: unquote(attrs)
})
end
end
defmacro module(module, do: block) do
attrs = Attr.extract_attrs_from_block_with_defaults(block)
quote do
Ejabberd.Config.Store.put(:modules, %EjabberdModule{
module: unquote(module),
attrs: unquote(attrs)
})
end
end
defmacro hook(hook_name, opts, fun) do
quote do
Ejabberd.Config.Store.put(:hooks, %Ejabberd.Config.EjabberdHook{
hook: unquote(hook_name),
opts: unquote(opts),
fun: unquote(fun)
})
end
end
# Private API
defp do_init(file_path) do
# File evaluation
Code.eval_file(file_path) |> extract_and_store_module_name()
# Getting start/0 config
Ejabberd.Config.Store.get(:module_name)
|> case do
nil -> IO.puts "[ ERR ] Configuration module not found."
[module] -> call_start_func_and_store_data(module)
end
# Fetching git modules and install them
get_modules_parsed_in_order()
|> EjabberdModule.fetch_git_repos
end
# Returns the modules from the store
defp get_modules_parsed_in_order,
do: Ejabberd.Config.Store.get(:modules) |> Enum.reverse
# Returns the listeners from the store
defp get_listeners_parsed_in_order,
do: Ejabberd.Config.Store.get(:listeners) |> Enum.reverse
defp get_hooks_parsed_in_order,
do: Ejabberd.Config.Store.get(:hooks) |> Enum.reverse
# Returns the general config options
defp get_general_opts,
do: Ejabberd.Config.Store.get(:general) |> List.first
# Gets the general ejabberd options calling
# the start/0 function and stores them.
defp call_start_func_and_store_data(module) do
opts = apply(module, :start, [])
Ejabberd.Config.Store.put(:general, opts)
end
# Stores the configuration module name
defp extract_and_store_module_name({{:module, mod, _bytes, _}, _}) do
Ejabberd.Config.Store.put(:module_name, mod)
end
end
ejabberd-18.01/lib/ejabberd/config/store.ex 0000644 0002322 0002322 00000002406 13225664356 021110 0 ustar debalance debalance defmodule Ejabberd.Config.Store do
@moduledoc """
Module used for storing the modules parsed from
the configuration file.
Example:
- Store.put(:modules, mod1)
- Store.put(:modules, mod2)
- Store.get(:modules) :: [mod1, mod2]
Be carefoul: when retrieving data you get them
in the order inserted into the store, which normally
is the reversed order of how the modules are specified
inside the configuration file. To resolve this just use
a Enum.reverse/1.
"""
@name __MODULE__
def start_link do
Agent.start_link(fn -> %{} end, name: @name)
end
@doc """
Stores a value based on the key. If the key already exists,
then it inserts the new element, maintaining all the others.
It uses a list for this.
"""
@spec put(atom, any) :: :ok
def put(key, val) do
Agent.update @name, &Map.update(&1, key, [val], fn coll ->
[val | coll]
end)
end
@doc """
Gets a value based on the key passed.
Returns always a list.
"""
@spec get(atom) :: [any]
def get(key) do
Agent.get @name, &Map.get(&1, key, [])
end
@doc """
Stops the store.
It uses Agent.stop underneath, so be aware that exit
could be called.
"""
@spec stop() :: :ok
def stop do
Agent.stop @name
end
end
ejabberd-18.01/lib/ejabberd/config/opts_formatter.ex 0000644 0002322 0002322 00000002475 13225664356 023032 0 ustar debalance debalance defmodule Ejabberd.Config.OptsFormatter do
@moduledoc """
Module for formatting options parsed into the format
ejabberd uses.
"""
alias Ejabberd.Config.EjabberdModule
@doc """
Takes a keyword list with keys corresponding to
the keys requested by the ejabberd config (ex: modules: mods)
and formats them to be correctly evaluated by ejabberd.
Look at how Config.get_ejabberd_opts/0 is constructed for
more informations.
"""
@spec format_opts_for_ejabberd([{atom(), any()}]) :: list()
def format_opts_for_ejabberd(opts) do
opts
|> format_attrs_for_ejabberd
end
defp format_attrs_for_ejabberd(opts) when is_list(opts),
do: Enum.map opts, &format_attrs_for_ejabberd/1
defp format_attrs_for_ejabberd({:listeners, mods}),
do: {:listen, format_listeners_for_ejabberd(mods)}
defp format_attrs_for_ejabberd({:modules, mods}),
do: {:modules, format_mods_for_ejabberd(mods)}
defp format_attrs_for_ejabberd({key, opts}) when is_atom(key),
do: {key, opts}
defp format_mods_for_ejabberd(mods) do
Enum.map mods, fn %EjabberdModule{module: mod, attrs: attrs} ->
{mod, attrs[:opts]}
end
end
defp format_listeners_for_ejabberd(mods) do
Enum.map mods, fn %EjabberdModule{module: mod, attrs: attrs} ->
Keyword.put(attrs[:opts], :module, mod)
end
end
end
ejabberd-18.01/lib/ejabberd/config/ejabberd_module.ex 0000644 0002322 0002322 00000004067 13225664356 023064 0 ustar debalance debalance defmodule Ejabberd.Config.EjabberdModule do
@moduledoc """
Module representing a module block in the configuration file.
It offers functions for validation and for starting the modules.
Warning: The name is EjabberdModule to not collide with
the already existing Elixir.Module.
"""
@type t :: %{module: atom, attrs: [Attr.t]}
defstruct [:module, :attrs]
alias Ejabberd.Config.EjabberdModule
alias Ejabberd.Config.Attr
alias Ejabberd.Config.Validation
@doc """
Given a list of modules / single module
it runs different validators on them.
For each module, returns a {:ok, mod} or {:error, mod, errors}
"""
def validate(modules) do
Validation.validate(modules)
end
@doc """
Given a list of modules, it takes only the ones with
a git attribute and tries to fetch the repo,
then, it install them through :ext_mod.install/1
"""
@spec fetch_git_repos([EjabberdModule.t]) :: none()
def fetch_git_repos(modules) do
modules
|> Enum.filter(&is_git_module?/1)
|> Enum.each(&fetch_and_install_git_module/1)
end
# Private API
defp is_git_module?(%EjabberdModule{attrs: attrs}) do
case Keyword.get(attrs, :git) do
"" -> false
repo -> String.match?(repo, ~r/((git|ssh|http(s)?)|(git@[\w\.]+))(:(\/\/)?)([\w\.@\:\/\-~]+)(\.git)(\/)?/)
end
end
defp fetch_and_install_git_module(%EjabberdModule{attrs: attrs}) do
repo = Keyword.get(attrs, :git)
mod_name = case Keyword.get(attrs, :name) do
"" -> infer_mod_name_from_git_url(repo)
name -> name
end
path = "#{:ext_mod.modules_dir()}/sources/ejabberd-contrib\/#{mod_name}"
fetch_and_store_repo_source_if_not_exists(path, repo)
:ext_mod.install(mod_name) # Have to check if overwrites an already present mod
end
defp fetch_and_store_repo_source_if_not_exists(path, repo) do
unless File.exists?(path) do
IO.puts "[info] Fetching: #{repo}"
:os.cmd('git clone #{repo} #{path}')
end
end
defp infer_mod_name_from_git_url(repo),
do: String.split(repo, "/") |> List.last |> String.replace(".git", "")
end
ejabberd-18.01/lib/ejabberd/logger.ex 0000644 0002322 0002322 00000000662 13225664356 017770 0 ustar debalance debalance defmodule Ejabberd.Logger do
def critical(message, args \\ []), do: :lager.log(:critical, [], message, args)
def error(message, args \\ []), do: :lager.log(:error, [], message, args)
def warning(message, args \\ []), do: :lager.log(:warning, [], message, args)
def info(message, args \\ []), do: :lager.log(:info, [], message, args)
def debug(message, args \\ []), do: :lager.log(:debug, [], message, args)
end
ejabberd-18.01/lib/ejabberd/hooks.ex 0000644 0002322 0002322 00000000563 13225664356 017634 0 ustar debalance debalance defmodule Ejabberd.Hooks do
# Generic hook setting features
def add(hook_name, host, module, function, priority) do
:ejabberd_hooks.add(hook_name, host, module, function, priority)
end
# Should be named 'removed'
def delete(hook_name, host, module, function, priority) do
:ejabberd_hooks.delete(hook_name, host, module, function, priority)
end
end
ejabberd-18.01/lib/mod_presence_demo.ex 0000644 0002322 0002322 00000000776 13225664356 020430 0 ustar debalance debalance defmodule ModPresenceDemo do
use Ejabberd.Module
def start(host, _opts) do
info('Starting ejabberd module Presence Demo')
Ejabberd.Hooks.add(:set_presence_hook, host, __MODULE__, :on_presence, 50)
:ok
end
def stop(host) do
info('Stopping ejabberd module Presence Demo')
Ejabberd.Hooks.delete(:set_presence_hook, host, __MODULE__, :on_presence, 50)
:ok
end
def on_presence(user, _server, _resource, _packet) do
info('Receive presence for #{user}')
:none
end
end
ejabberd-18.01/rel/ 0000755 0002322 0002322 00000000000 13225664356 014425 5 ustar debalance debalance ejabberd-18.01/rel/files/ 0000755 0002322 0002322 00000000000 13225664356 015527 5 ustar debalance debalance ejabberd-18.01/rel/files/install_upgrade.escript 0000644 0002322 0002322 00000003256 13225664356 022305 0 ustar debalance debalance #!/usr/bin/env escript
%%! -noshell -noinput
%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
%% ex: ft=erlang ts=4 sw=4 et
-define(TIMEOUT, 60000).
-define(INFO(Fmt,Args), io:format(Fmt,Args)).
main([NodeName, Cookie, ReleasePackage]) ->
TargetNode = start_distribution(NodeName, Cookie),
{ok, Vsn} = rpc:call(TargetNode, release_handler, unpack_release,
[ReleasePackage], ?TIMEOUT),
?INFO("Unpacked Release ~p~n", [Vsn]),
{ok, OtherVsn, Desc} = rpc:call(TargetNode, release_handler,
check_install_release, [Vsn], ?TIMEOUT),
{ok, OtherVsn, Desc} = rpc:call(TargetNode, release_handler,
install_release, [Vsn], ?TIMEOUT),
?INFO("Installed Release ~p~n", [Vsn]),
ok = rpc:call(TargetNode, release_handler, make_permanent, [Vsn], ?TIMEOUT),
?INFO("Made Release ~p Permanent~n", [Vsn]);
main(_) ->
init:stop(1).
start_distribution(NodeName, Cookie) ->
MyNode = make_script_node(NodeName),
{ok, _Pid} = net_kernel:start([MyNode, shortnames]),
erlang:set_cookie(node(), list_to_atom(Cookie)),
TargetNode = make_target_node(NodeName),
case {net_kernel:hidden_connect_node(TargetNode),
net_adm:ping(TargetNode)} of
{true, pong} ->
ok;
{_, pang} ->
io:format("Node ~p not responding to pings.\n", [TargetNode]),
init:stop(1)
end,
TargetNode.
make_target_node(Node) ->
[_, Host] = string:tokens(atom_to_list(node()), "@"),
list_to_atom(lists:concat([Node, "@", Host])).
make_script_node(Node) ->
list_to_atom(lists:concat([Node, "_upgrader_", os:getpid()])).
ejabberd-18.01/rel/files/erl 0000755 0002322 0002322 00000002136 13225664356 016241 0 ustar debalance debalance #!/bin/sh
## This script replaces the default "erl" in erts-VSN/bin. This is necessary
## as escript depends on erl and in turn, erl depends on having access to a
## bootscript (start.boot). Note that this script is ONLY invoked as a side-effect
## of running escript -- the embedded node bypasses erl and uses erlexec directly
## (as it should).
##
## Note that this script makes the assumption that there is a start_clean.boot
## file available in $ROOTDIR/release/VSN.
# Determine the abspath of where this script is executing from.
ERTS_BIN_DIR=$(cd ${0%/*} && pwd)
# Now determine the root directory -- this script runs from erts-VSN/bin,
# so we simply need to strip off two dirs from the end of the ERTS_BIN_DIR
# path.
ROOTDIR=${ERTS_BIN_DIR%/*/*}
# Parse out release and erts info
START_ERL=`cat $ROOTDIR/releases/start_erl.data`
ERTS_VSN=${START_ERL% *}
APP_VSN=${START_ERL#* }
BINDIR=$ROOTDIR/erts-$ERTS_VSN/bin
EMU=beam
PROGNAME=`echo $0 | sed 's/.*\\///'`
CMD="$BINDIR/erlexec"
export EMU
export ROOTDIR
export BINDIR
export PROGNAME
exec $CMD -boot $ROOTDIR/releases/$APP_VSN/start_clean ${1+"$@"}
ejabberd-18.01/rel/reltool.config.script 0000644 0002322 0002322 00000010172 13225664356 020600 0 ustar debalance debalance %%%-------------------------------------------------------------------
%%% @author Evgeniy Khramtsov
%%% @copyright (C) 2013-2017, Evgeniy Khramtsov
%%% @doc
%%%
%%% @end
%%% Created : 8 May 2013 by Evgeniy Khramtsov
%%%-------------------------------------------------------------------
TopDir = filename:join(filename:dirname(SCRIPT), ".."),
GetDeps = fun(Config, GetDepsFun) ->
case catch rebar_config:consult_file(Config) of
{ok, Data} ->
case lists:keyfind(deps, 1, Data) of
{deps, Deps} ->
lists:map(fun({Dep, _, _}) ->
[Dep, GetDepsFun(filename:join([TopDir,
"deps",
Dep,
"rebar.config"]),
GetDepsFun)]
end, Deps);
_ ->
[]
end;
_ ->
[]
end
end,
Vars = case file:consult(filename:join([TopDir, "vars.config"])) of
{ok, Terms} ->
Terms;
_Err ->
[]
end,
RequiredOTPApps = [sasl, crypto, public_key, ssl,
mnesia, inets, compiler, asn1,
syntax_tools, os_mon, xmerl],
ConfiguredOTPApps = lists:flatmap(
fun({tools, true}) ->
[tools, runtime_tools];
({odbc, true}) ->
[odbc];
(_) ->
[]
end, Vars),
OTPApps = RequiredOTPApps ++ ConfiguredOTPApps,
DepApps = lists:usort(lists:flatten(GetDeps(filename:join(TopDir, "rebar.config"), GetDeps))),
Sys = [{lib_dirs, []},
{erts, [{mod_cond, derived}, {app_file, strip}]},
{app_file, strip},
{rel, "ejabberd", proplists:get_value(vsn, Vars),
[
kernel,
stdlib,
ejabberd
] ++ OTPApps ++ DepApps},
{rel, "start_clean", "",
[
kernel,
stdlib
]},
{boot_rel, "ejabberd"},
{profile, embedded},
{incl_cond, exclude},
{excl_archive_filters, [".*"]}, %% Do not archive built libs
{excl_sys_filters, ["^bin/.*", "^erts.*/bin/(dialyzer|typer)",
"^erts.*/(doc|info|include|lib|man|src)"]},
{excl_app_filters, ["\.gitignore"]},
{app, stdlib, [{incl_cond, include}]},
{app, kernel, [{incl_cond, include}]},
{app, ejabberd, [{incl_cond, include}, {lib_dir, ".."}]}]
++ lists:map(
fun(App) ->
{app, App, [{incl_cond, include},
{lib_dir, "../deps/" ++ atom_to_list(App)}]}
end, DepApps)
++ lists:map(
fun(App) ->
{app, App, [{incl_cond, include}]}
end, OTPApps).
Overlay = [
{mkdir, "var/log/ejabberd"},
{mkdir, "var/lock"},
{mkdir, "var/lib/ejabberd"},
{mkdir, "etc/ejabberd"},
{mkdir, "doc"},
{template, "files/erl", "\{\{erts_vsn\}\}/bin/erl"},
{template, "../ejabberdctl.template", "bin/ejabberdctl"},
{copy, "../ejabberdctl.cfg.example", "etc/ejabberd/ejabberdctl.cfg"},
{copy, "../ejabberd.yml.example", "etc/ejabberd/ejabberd.yml"},
{copy, "../inetrc", "etc/ejabberd/inetrc"},
{copy, "files/install_upgrade.escript", "bin/install_upgrade.escript"}
],
Config = [{sys, Sys},
{overlay_vars, "../vars.config"},
{target_dir, "ejabberd"},
{overlay, Overlay}],
%%io:format("ejabberd release:~n ~p~n", [Config]),
Config.
%% Local Variables:
%% mode: erlang
%% End:
%% vim: set filetype=erlang tabstop=8:
ejabberd-18.01/ejabberdctl.template 0000755 0002322 0002322 00000024517 13225664356 017655 0 ustar debalance debalance #!/bin/sh
# define default configuration
POLL=true
SMP=auto
ERL_MAX_PORTS=32000
ERL_PROCESSES=250000
ERL_MAX_ETS_TABLES=1400
FIREWALL_WINDOW=""
INET_DIST_INTERFACE=""
ERLANG_NODE=ejabberd@localhost
# define default environment variables
SCRIPT_DIR=$(cd "${0%/*}" && pwd)
ERL="{{erl}}"
IEX="{{bindir}}/iex"
EPMD="{{epmd}}"
INSTALLUSER="{{installuser}}"
# check the proper system user is used
case $(id -un) in
"$INSTALLUSER")
EXEC_CMD="as_current_user"
;;
root)
if [ -n "$INSTALLUSER" ] ; then
EXEC_CMD="as_install_user"
else
EXEC_CMD="as_current_user"
echo "WARNING: This is not recommended to run ejabberd as root" >&2
fi
;;
*)
if [ -n "$INSTALLUSER" ] ; then
echo "ERROR: This command can only be run by root or the user $INSTALLUSER" >&2
exit 7
else
EXEC_CMD="as_current_user"
fi
;;
esac
# parse command line parameters
for arg; do
case $arg in
-n|--node) ERLANG_NODE_ARG=$2; shift;;
-s|--spool) SPOOL_DIR=$2; shift;;
-l|--logs) LOGS_DIR=$2; shift;;
-f|--config) EJABBERD_CONFIG_PATH=$2; shift;;
-c|--ctl-config) EJABBERDCTL_CONFIG_PATH=$2; shift;;
-d|--config-dir) ETC_DIR=$2; shift;;
-t|--no-timeout) NO_TIMEOUT="--no-timeout";;
--) :;;
*) break;;
esac
shift
done
# define ejabberd variables if not already defined from the command line
: "${ETC_DIR:="{{sysconfdir}}/ejabberd"}"
: "${LOGS_DIR:="{{localstatedir}}/log/ejabberd"}"
: "${SPOOL_DIR:="{{localstatedir}}/lib/ejabberd"}"
: "${EJABBERD_CONFIG_PATH:="$ETC_DIR/ejabberd.yml"}"
: "${EJABBERDCTL_CONFIG_PATH:="$ETC_DIR/ejabberdctl.cfg"}"
[ -f "$EJABBERDCTL_CONFIG_PATH" ] && . "$EJABBERDCTL_CONFIG_PATH"
[ -n "$ERLANG_NODE_ARG" ] && ERLANG_NODE="$ERLANG_NODE_ARG"
[ "$ERLANG_NODE" = "${ERLANG_NODE%.*}" ] && S="-s"
: "${EJABBERD_DOC_PATH:="{{docdir}}"}"
: "${EJABBERD_LOG_PATH:="$LOGS_DIR/ejabberd.log"}"
# define erl parameters
ERLANG_OPTS="+K $POLL -smp $SMP +P $ERL_PROCESSES $ERL_OPTIONS"
if [ -n "$FIREWALL_WINDOW" ] ; then
ERLANG_OPTS="$ERLANG_OPTS -kernel inet_dist_listen_min ${FIREWALL_WINDOW%-*} inet_dist_listen_max ${FIREWALL_WINDOW#*-}"
fi
if [ -n "$INET_DIST_INTERFACE" ] ; then
INET_DIST_INTERFACE2=$("$ERL" -noshell -eval 'case inet:parse_address("'$INET_DIST_INTERFACE'") of {ok,IP} -> io:format("~p",[IP]); _ -> ok end.' -s erlang halt)
if [ -n "$INET_DIST_INTERFACE2" ] ; then
ERLANG_OPTS="$ERLANG_OPTS -kernel inet_dist_use_interface $INET_DIST_INTERFACE2"
fi
fi
ERL_LIBS={{libdir}}
ERL_CRASH_DUMP="$LOGS_DIR"/erl_crash_$(date "+%Y%m%d-%H%M%S").dump
ERL_INETRC="$ETC_DIR"/inetrc
# define ejabberd parameters
EJABBERD_OPTS="$EJABBERD_OPTS\
$(sed '/^log_rate_limit/!d;s/:[ \t]*\([0-9]*\).*/ \1/;s/^/ /' "$EJABBERD_CONFIG_PATH")\
$(sed '/^log_rotate_size/!d;s/:[ \t]*\([0-9]*\).*/ \1/;s/^/ /' "$EJABBERD_CONFIG_PATH")\
$(sed '/^log_rotate_count/!d;s/:[ \t]*\([0-9]*\).*/ \1/;s/^/ /' "$EJABBERD_CONFIG_PATH")\
$(sed '/^log_rotate_date/!d;s/:[ \t]*\(.[^ ]*\).*/ \1/;s/^/ /' "$EJABBERD_CONFIG_PATH")"
[ -n "$EJABBERD_OPTS" ] && EJABBERD_OPTS="-ejabberd $EJABBERD_OPTS"
EJABBERD_OPTS="-mnesia dir \"$SPOOL_DIR\" $MNESIA_OPTIONS $EJABBERD_OPTS -s ejabberd"
# export global variables
export EJABBERD_CONFIG_PATH
export EJABBERD_LOG_PATH
export EJABBERD_DOC_PATH
export EJABBERD_PID_PATH
export ERL_CRASH_DUMP
export ERL_EPMD_ADDRESS
export ERL_INETRC
export ERL_MAX_PORTS
export ERL_MAX_ETS_TABLES
export CONTRIB_MODULES_PATH
export CONTRIB_MODULES_CONF_DIR
export ERL_LIBS
# run command either directly or via su $INSTALLUSER
exec_cmd()
{
case $EXEC_CMD in
as_install_user) su -s /bin/sh -c '"$0" "$@"' "$INSTALLUSER" -- "$@" ;;
as_current_user) "$@" ;;
esac
}
exec_erl()
{
NODE=$1; shift
exec_cmd "$ERL" ${S:--}name "$NODE" $ERLANG_OPTS "$@"
}
exec_iex()
{
NODE=$1; shift
exec_cmd "$IEX" -${S:--}name "$NODE" --erl "$ERLANG_OPTS" "$@"
}
# usage
debugwarning()
{
if [ "$EJABBERD_BYPASS_WARNINGS" != "true" ] ; then
echo "--------------------------------------------------------------------"
echo ""
echo "IMPORTANT: we will attempt to attach an INTERACTIVE shell"
echo "to an already running ejabberd node."
echo "If an ERROR is printed, it means the connection was not successful."
echo "You can interact with the ejabberd node if you know how to use it."
echo "Please be extremely cautious with your actions,"
echo "and exit immediately if you are not completely sure."
echo ""
echo "To detach this shell from ejabberd, press:"
echo " control+c, control+c"
echo ""
echo "--------------------------------------------------------------------"
echo "To bypass permanently this warning, add to ejabberdctl.cfg the line:"
echo " EJABBERD_BYPASS_WARNINGS=true"
echo "Press return to continue"
read -r input
echo ""
fi
}
livewarning()
{
if [ "$EJABBERD_BYPASS_WARNINGS" != "true" ] ; then
echo "--------------------------------------------------------------------"
echo ""
echo "IMPORTANT: ejabberd is going to start in LIVE (interactive) mode."
echo "All log messages will be shown in the command shell."
echo "You can interact with the ejabberd node if you know how to use it."
echo "Please be extremely cautious with your actions,"
echo "and exit immediately if you are not completely sure."
echo ""
echo "To exit this LIVE mode and stop ejabberd, press:"
echo " q(). and press the Enter key"
echo ""
echo "--------------------------------------------------------------------"
echo "To bypass permanently this warning, add to ejabberdctl.cfg the line:"
echo " EJABBERD_BYPASS_WARNINGS=true"
echo "Press return to continue"
read -r input
echo ""
fi
}
help()
{
echo ""
echo "Commands to start an ejabberd node:"
echo " start Start an ejabberd node in server mode"
echo " debug Attach an interactive Erlang shell to a running ejabberd node"
echo " iexdebug Attach an interactive Elixir shell to a running ejabberd node"
echo " live Start an ejabberd node in live (interactive) mode"
echo " iexlive Start an ejabberd node in live (interactive) mode, within an Elixir shell"
echo " foreground Start an ejabberd node in server mode (attached)"
echo ""
echo "Optional parameters when starting an ejabberd node:"
echo " --config-dir dir Config ejabberd: $ETC_DIR"
echo " --config file Config ejabberd: $EJABBERD_CONFIG_PATH"
echo " --ctl-config file Config ejabberdctl: $EJABBERDCTL_CONFIG_PATH"
echo " --logs dir Directory for logs: $LOGS_DIR"
echo " --spool dir Database spool dir: $SPOOL_DIR"
echo " --node nodename ejabberd node name: $ERLANG_NODE"
echo ""
}
# dynamic node name helper
uid()
{
uuid=$(uuidgen 2>/dev/null)
[ -z "$uuid" ] && [ -f /proc/sys/kernel/random/uuid ] && uuid=$(cat /proc/sys/kernel/random/uuid)
[ -z "$uuid" ] && uuid=$(printf "%X" "${RANDOM:-$$}$(date +%M%S)")
uuid=${uuid%%-*}
[ $# -eq 0 ] && echo "${uuid}-${ERLANG_NODE}"
[ $# -eq 1 ] && echo "${uuid}-${1}-${ERLANG_NODE}"
[ $# -eq 2 ] && echo "${uuid}-${1}@${2}"
}
# stop epmd if there is no other running node
stop_epmd()
{
"$EPMD" -names 2>/dev/null | grep -q name || "$EPMD" -kill >/dev/null
}
# make sure node not already running and node name unregistered
# if all ok, ensure runtime directory exists and make it current directory
check_start()
{
"$EPMD" -names 2>/dev/null | grep -q " ${ERLANG_NODE%@*} " && {
pgrep -f "$ERLANG_NODE" >/dev/null && {
echo "ERROR: The ejabberd node '$ERLANG_NODE' is already running."
exit 4
}
pgrep beam >/dev/null && {
echo "ERROR: The ejabberd node '$ERLANG_NODE' is registered,"
echo " but no related beam process has been found."
echo "Shutdown all other erlang nodes, and call 'epmd -kill'."
exit 5
}
"$EPMD" -kill >/dev/null
}
}
# allow sync calls
wait_status()
{
# args: status try delay
# return: 0 OK, 1 KO
timeout="$2"
status=4
while [ "$status" -ne "$1" ] ; do
sleep "$3"
timeout=$((timeout - 1))
if [ $timeout -eq 0 ] ; then
status="$1"
else
exec_erl "$(uid ctl)" -hidden -noinput -s ejabberd_ctl \
-extra "$ERLANG_NODE" $NO_TIMEOUT status > /dev/null
status="$?"
fi
done
[ $timeout -gt 0 ]
}
# ensure we can change current directory to SPOOL_DIR
[ -d "$SPOOL_DIR" ] || exec_cmd mkdir -p "$SPOOL_DIR"
cd "$SPOOL_DIR" || {
echo "ERROR: can not access directory $SPOOL_DIR"
exit 6
}
# main
case $1 in
start)
check_start
exec_erl "$ERLANG_NODE" $EJABBERD_OPTS -noinput -detached
;;
foreground)
check_start
exec_erl "$ERLANG_NODE" $EJABBERD_OPTS -noinput
;;
live)
livewarning
check_start
exec_erl "$ERLANG_NODE" $EJABBERD_OPTS
;;
debug)
debugwarning
exec_erl "$(uid debug)" -hidden -remsh "$ERLANG_NODE"
;;
etop)
exec_erl "$(uid top)" -hidden -node "$ERLANG_NODE" -s etop \
-s erlang halt -output text
;;
iexdebug)
debugwarning
exec_iex "$(uid debug)" --remsh "$ERLANG_NODE"
;;
iexlive)
livewarning
exec_iex "$ERLANG_NODE" --erl "$EJABBERD_OPTS" --app ejabberd
;;
ping)
PEER=${2:-$ERLANG_NODE}
[ "$PEER" = "${PEER%.*}" ] && PS="-s"
exec_cmd "$ERL" ${PS:--}name "$(uid ping "$(hostname $PS)")" $ERLANG_OPTS \
-noinput -hidden -eval 'io:format("~p~n",[net_adm:ping('"'$PEER'"')])' \
-s erlang halt -output text
;;
started)
wait_status 0 30 2 # wait 30x2s before timeout
;;
stopped)
wait_status 3 30 2 && stop_epmd # wait 30x2s before timeout
;;
*)
exec_erl "$(uid ctl)" -hidden -noinput -s ejabberd_ctl \
-extra "$ERLANG_NODE" $NO_TIMEOUT "$@"
result=$?
case $result in
2|3) help;;
*) :;;
esac
exit $result
;;
esac
ejabberd-18.01/configure.bat 0000644 0002322 0002322 00000000457 13225664356 016322 0 ustar debalance debalance
@if "x%1"=="x--help" goto usage
@set arg=dynamic
@if "x%1"=="x--static" set arg=static
@echo Configuring for %arg% build...
erlc configure.erl
erl -s configure -env arg %arg% -noshell
@goto end
:usage
@echo Usage: configure.bat
@echo or configure.bat --static
@echo or configure.bat --help
:end
ejabberd-18.01/mix.lock 0000644 0002322 0002322 00000012554 13225664356 015321 0 ustar debalance debalance %{"cache_tab": {:hex, :cache_tab, "1.0.12", "a06a4ffbd4da8469791ba941512a6a45ed8c11865b4606a368e21b332da3638a", [:rebar3], [{:p1_utils, "1.0.10", [hex: :p1_utils, repo: "hexpm", optional: false]}], "hexpm"},
"distillery": {:hex, :distillery, "1.5.2", "eec18b2d37b55b0bcb670cf2bcf64228ed38ce8b046bb30a9b636a6f5a4c0080", [:mix], [], "hexpm"},
"earmark": {:hex, :earmark, "1.2.4", "99b637c62a4d65a20a9fb674b8cffb8baa771c04605a80c911c4418c69b75439", [:mix], [], "hexpm"},
"eimp": {:git, "https://github.com/processone/eimp.git", "23796118176be98195db9f831f17dde74d1553e1", [tag: "1.0.1"]},
"epam": {:hex, :epam, "1.0.3", "3adcc148cdbaaa2bbe15dd661f0d74284e5749a815b4e480dbf94e8e023361b9", [:rebar3], [], "hexpm"},
"eredis": {:hex, :eredis, "1.1.0", "8d8d74496f35216679b97726b75fb1c8715e99dd7f3ef9f9824a2264c3e0aac0", [:rebar3], [], "hexpm"},
"esip": {:hex, :esip, "1.0.21", "711c704337d434db6d7c70bd0da868aaacd91b252c0bb63b4580e6c896164f1f", [:rebar3], [{:fast_tls, "1.0.20", [hex: :fast_tls, repo: "hexpm", optional: false]}, {:p1_utils, "1.0.10", [hex: :p1_utils, repo: "hexpm", optional: false]}, {:stun, "1.0.20", [hex: :stun, repo: "hexpm", optional: false]}], "hexpm"},
"ex_doc": {:hex, :ex_doc, "0.18.1", "37c69d2ef62f24928c1f4fdc7c724ea04aecfdf500c4329185f8e3649c915baf", [:mix], [{:earmark, "~> 1.1", [hex: :earmark, repo: "hexpm", optional: false]}], "hexpm"},
"ezlib": {:git, "https://github.com/processone/ezlib.git", "ec6491d788436bb096022843e6ec7f58d2973ae3", [tag: "1.0.3"]},
"fast_tls": {:hex, :fast_tls, "1.0.20", "edd241961ab20b71ec1e9f75a2a2c043128ff117adf3efd42e6cec94f1937539", [:rebar3], [{:p1_utils, "1.0.10", [hex: :p1_utils, repo: "hexpm", optional: false]}], "hexpm"},
"fast_xml": {:hex, :fast_xml, "1.1.28", "31ce5cf44d20e900e1a499009f886ff74b589324d532ed0ed7a432e4f498beb1", [:rebar3], [{:p1_utils, "1.0.10", [hex: :p1_utils, repo: "hexpm", optional: false]}], "hexpm"},
"fast_yaml": {:hex, :fast_yaml, "1.0.12", "ee8527d388255cf7a24fc1e6cb2d09dca4e506966dd9d86e61d3d90f236a3e2e", [:rebar3], [{:p1_utils, "1.0.10", [hex: :p1_utils, repo: "hexpm", optional: false]}], "hexpm"},
"fs": {:hex, :fs, "3.4.0", "6d18575c250b415b3cad559e6f97a4c822516c7bc2c10bfbb2493a8f230f5132", [:rebar3], [], "hexpm"},
"goldrush": {:hex, :goldrush, "0.1.9", "f06e5d5f1277da5c413e84d5a2924174182fb108dabb39d5ec548b27424cd106", [:rebar3], [], "hexpm"},
"hamcrest": {:hex, :basho_hamcrest, "0.4.1", "fb7b2c92d252a1e9db936750b86089addaebeb8f87967fb4bbdda61e8863338e", [:make, :mix, :rebar3], [], "hexpm"},
"iconv": {:hex, :iconv, "1.0.6", "3b424a80039059767f1037dc6a49ff07c2f88df14068c16dc938c4f377a77b4c", [:rebar3], [{:p1_utils, "1.0.10", [hex: :p1_utils, repo: "hexpm", optional: false]}], "hexpm"},
"jiffy": {:hex, :jiffy, "0.14.13", "225a9a35e26417832c611526567194b4d3adc4f0dfa5f2f7008f4684076f2a01", [:rebar3], [], "hexpm"},
"lager": {:hex, :lager, "3.4.2", "150b9a17b23ae6d3265cc10dc360747621cf217b7a22b8cddf03b2909dbf7aa5", [:rebar3], [{:goldrush, "0.1.9", [hex: :goldrush, repo: "hexpm", optional: false]}], "hexpm"},
"luerl": {:git, "https://github.com/rvirding/luerl.git", "f7b2cc0ab6fa4245ebeda0169fc994aff0628bf9", [tag: "v0.2"]},
"meck": {:hex, :meck, "0.8.9", "64c5c0bd8bcca3a180b44196265c8ed7594e16bcc845d0698ec6b4e577f48188", [:rebar3], [], "hexpm"},
"moka": {:git, "https://github.com/processone/moka.git", "3eed3a6dd7dedb70a6cd18f86c7561a18626eb3b", [tag: "1.0.5c"]},
"p1_mysql": {:hex, :p1_mysql, "1.0.4", "7b9d7957a9d031813a0e6bcea5a7f5e91b54db805a92709a445cf75cf934bc1d", [:rebar3], [], "hexpm"},
"p1_oauth2": {:hex, :p1_oauth2, "0.6.2", "cc381038920e3d34ef32aa10ba7eb637bdff38a946748c4fd99329ff484a3889", [:rebar3], [], "hexpm"},
"p1_pgsql": {:hex, :p1_pgsql, "1.1.4", "eadbbddee8d52145694bf86bdfe8c1ae8353a55e152410146b8c2711756d6041", [:rebar3], [], "hexpm"},
"p1_utils": {:hex, :p1_utils, "1.0.10", "a6d6927114bac79cf6468a10824125492034af7071adc6ed5ebc4ddb443845d4", [:rebar3], [], "hexpm"},
"riak_pb": {:hex, :riak_pb, "2.3.2", "48ffbf66dbb3f136ab9a7134bac4e496754baa5ef58c4f50a61326736d996390", [:make, :mix, :rebar3], [{:hamcrest, "~> 0.4.1", [hex: :basho_hamcrest, repo: "hexpm", optional: false]}], "hexpm"},
"riakc": {:hex, :riakc, "2.5.3", "6132d9e687a0dfd314b2b24c4594302ca8b55568a5d733c491d8fb6cd4004763", [:make, :mix, :rebar3], [{:riak_pb, "~> 2.3", [hex: :riak_pb, repo: "hexpm", optional: false]}], "hexpm"},
"samerlib": {:git, "https://github.com/processone/samerlib", "fbbba035b1548ac4e681df00d61bf609645333a0", [tag: "0.8.0c"]},
"sqlite3": {:hex, :sqlite3, "1.1.5", "794738b6d07b6d36ec6d42492cb9d629bad9cf3761617b8b8d728e765db19840", [:rebar3], [], "hexpm"},
"stringprep": {:hex, :stringprep, "1.0.10", "552d784eb60652220fce9131f8bb0ebc62fdffd6482c4f08f2e7d61300227c28", [:rebar3], [{:p1_utils, "1.0.10", [hex: :p1_utils, repo: "hexpm", optional: false]}], "hexpm"},
"stun": {:hex, :stun, "1.0.20", "6b156fa11606bebb6086d02cb2f6532c84effb59c95ba93d0e2d8e2510970253", [:rebar3], [{:fast_tls, "1.0.20", [hex: :fast_tls, repo: "hexpm", optional: false]}, {:p1_utils, "1.0.10", [hex: :p1_utils, repo: "hexpm", optional: false]}], "hexpm"},
"xmpp": {:hex, :xmpp, "1.1.19", "ca0a89c567e972d119204b1296ffe58ad5d3237738950ae2c61043fbaf5e150e", [:rebar3], [{:fast_xml, "1.1.28", [hex: :fast_xml, repo: "hexpm", optional: false]}, {:p1_utils, "1.0.10", [hex: :p1_utils, repo: "hexpm", optional: false]}, {:stringprep, "1.0.10", [hex: :stringprep, repo: "hexpm", optional: false]}], "hexpm"}}
ejabberd-18.01/README.md 0000777 0002322 0002322 00000000000 13225664356 015777 2README ustar debalance debalance ejabberd-18.01/vars.config.in 0000644 0002322 0002322 00000004143 13225664356 016414 0 ustar debalance debalance %%%----------------------------------------------------------------------
%%%
%%% ejabberd, Copyright (C) 2002-2017 ProcessOne
%%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as
%%% published by the Free Software Foundation; either version 2 of the
%%% License, or (at your option) any later version.
%%%
%%% This program is distributed in the hope that it will be useful,
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
%%% General Public License for more details.
%%%
%%% You should have received a copy of the GNU General Public License along
%%% with this program; if not, write to the Free Software Foundation, Inc.,
%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
%%%
%%%----------------------------------------------------------------------
%% Macros
{roster_gateway_workaround, @roster_gateway_workaround@}.
{full_xml, @full_xml@}.
{db_type, @db_type@}.
{debug, @debug@}.
{hipe, @hipe@}.
{erlang_deprecated_types, @erlang_deprecated_types@}.
{new_sql_schema, @new_sql_schema@}.
%% Ad-hoc directories with source files
{tools, @tools@}.
%% Dependencies
{odbc, @odbc@}.
{mysql, @mysql@}.
{pgsql, @pgsql@}.
{sqlite, @sqlite@}.
{pam, @pam@}.
{zlib, @zlib@}.
{riak, @riak@}.
{redis, @redis@}.
{elixir, @elixir@}.
{iconv, @iconv@}.
{stun, @stun@}.
{sip, @sip@}.
{graphics, @graphics@}.
%% Version
{vsn, "@PACKAGE_VERSION@"}.
%% Variables for overlay template files
%% Platform-specific installation paths
{release, true}.
{release_dir, "${SCRIPT_DIR%/*}"}.
{sysconfdir, "{{release_dir}}/etc"}.
{installuser, "@INSTALLUSER@"}.
{erl, "{{release_dir}}/{{erts_vsn}}/bin/erl"}.
{epmd, "{{release_dir}}/{{erts_vsn}}/bin/epmd"}.
{localstatedir, "{{release_dir}}/var"}.
{libdir, "{{release_dir}}/lib"}.
{docdir, "{{release_dir}}/doc"}.
{latest_deps, @latest_deps@}.
{system_deps, @system_deps@}.
{ldflags, "@LDFLAGS@"}.
{cflags, "@CFLAGS@"}.
{cppflags, "@CPPFLAGS@"}.
%% Local Variables:
%% mode: erlang
%% End:
%% vim: set filetype=erlang tabstop=8:
ejabberd-18.01/ejabberdctl.cfg.example 0000644 0002322 0002322 00000013144 13225664356 020222 0 ustar debalance debalance #
# In this file you can configure options that are passed by ejabberdctl
# to the erlang runtime system when starting ejabberd
#
#' POLL: Kernel polling ([true|false])
#
# The kernel polling option requires support in the kernel.
# Additionally, you need to enable this feature while compiling Erlang.
#
# Default: true
#
#POLL=true
#.
#' SMP: SMP support ([enable|auto|disable])
#
# Explanation in Erlang/OTP documentation:
# enable: starts the Erlang runtime system with SMP support enabled.
# This may fail if no runtime system with SMP support is available.
# auto: starts the Erlang runtime system with SMP support enabled if it
# is available and more than one logical processor are detected.
# disable: starts a runtime system without SMP support.
#
# Default: auto
#
#SMP=auto
#.
#' ERL_MAX_PORTS: Maximum number of simultaneously open Erlang ports
#
# ejabberd consumes two or three ports for every connection, either
# from a client or from another Jabber server. So take this into
# account when setting this limit.
#
# Default: 32000
# Maximum: 268435456
#
#ERL_MAX_PORTS=32000
#.
#' FIREWALL_WINDOW: Range of allowed ports to pass through a firewall
#
# If Ejabberd is configured to run in cluster, and a firewall is blocking ports,
# it's possible to make Erlang use a defined range of port (instead of dynamic
# ports) for node communication.
#
# Default: not defined
# Example: 4200-4210
#
#FIREWALL_WINDOW=
#.
#' INET_DIST_INTERFACE: IP address where this Erlang node listens other nodes
#
# This communication is used by ejabberdctl command line tool,
# and in a cluster of several ejabberd nodes.
#
# Default: 0.0.0.0
#
#INET_DIST_INTERFACE=127.0.0.1
#.
#' ERL_EPMD_ADDRESS: IP addresses where epmd listens for connections
#
# IMPORTANT: This option works only in Erlang/OTP R14B03 and newer.
#
# This environment variable may be set to a comma-separated
# list of IP addresses, in which case the epmd daemon
# will listen only on the specified address(es) and on the
# loopback address (which is implicitly added to the list if it
# has not been specified). The default behaviour is to listen on
# all available IP addresses.
#
# Default: 0.0.0.0
#
#ERL_EPMD_ADDRESS=127.0.0.1
#.
#' ERL_PROCESSES: Maximum number of Erlang processes
#
# Erlang consumes a lot of lightweight processes. If there is a lot of activity
# on ejabberd so that the maximum number of processes is reached, people will
# experience greater latency times. As these processes are implemented in
# Erlang, and therefore not related to the operating system processes, you do
# not have to worry about allowing a huge number of them.
#
# Default: 250000
# Maximum: 268435456
#
#ERL_PROCESSES=250000
#.
#' ERL_MAX_ETS_TABLES: Maximum number of ETS and Mnesia tables
#
# The number of concurrent ETS and Mnesia tables is limited. When the limit is
# reached, errors will appear in the logs:
# ** Too many db tables **
# You can safely increase this limit when starting ejabberd. It impacts memory
# consumption but the difference will be quite small.
#
# Default: 1400
#
#ERL_MAX_ETS_TABLES=1400
#.
#' ERL_OPTIONS: Additional Erlang options
#
# The next variable allows to specify additional options passed to erlang while
# starting ejabberd. Some useful options are -noshell, -detached, -heart. When
# ejabberd is started from an init.d script options -noshell and -detached are
# added implicitly. See erl(1) for more info.
#
# It might be useful to add "-pa /usr/local/lib/ejabberd/ebin" if you
# want to add local modules in this path.
#
# Default: ""
#
#ERL_OPTIONS=""
#.
#' ERLANG_NODE: Erlang node name
#
# The next variable allows to explicitly specify erlang node for ejabberd
# It can be given in different formats:
# ERLANG_NODE=ejabberd
# Lets erlang add hostname to the node (ejabberd uses short name in this case)
# ERLANG_NODE=ejabberd@hostname
# Erlang uses node name as is (so make sure that hostname is a real
# machine hostname or you'll not be able to control ejabberd)
# ERLANG_NODE=ejabberd@hostname.domainname
# The same as previous, but erlang will use long hostname
# (see erl (1) manual for details)
#
# Default: ejabberd@localhost
#
#ERLANG_NODE=ejabberd@localhost
#.
#' EJABBERD_PID_PATH: ejabberd PID file
#
# Indicate the full path to the ejabberd Process identifier (PID) file.
# If this variable is defined, ejabberd writes the PID file when starts,
# and deletes it when stops.
# Remember to create the directory and grant write permission to ejabberd.
#
# Default: don't write PID file
#
#EJABBERD_PID_PATH=/var/run/ejabberd/ejabberd.pid
#.
#' EJABBERD_CONFIG_PATH: ejabberd configuration file
#
# Specify the full path to the ejabberd configuration file. If the file name has
# yml or yaml extension, it is parsed as a YAML file; otherwise, Erlang syntax is
# expected.
#
# Default: $ETC_DIR/ejabberd.yml
#
#EJABBERD_CONFIG_PATH=/etc/ejabberd/ejabberd.yml
#.
#' CONTRIB_MODULES_PATH: contributed ejabberd modules path
#
# Specify the full path to the contributed ejabberd modules. If the path is not
# defined, ejabberd will use ~/.ejabberd-modules in home of user running ejabberd.
#
# Default: $HOME/.ejabberd-modules
#
#CONTRIB_MODULES_PATH=/opt/ejabberd-modules
#.
#' CONTRIB_MODULES_CONF_DIR: configuration directory for contributed modules
#
# Specify the full path to the configuration directory for contributed ejabberd
# modules. In order to configure a module named mod_foo, a mod_foo.yml file can
# be created in this directory. This file will then be used instead of the
# default configuration file provided with the module.
#
# Default: $CONTRIB_MODULES_PATH/conf
#
#CONTRIB_MODULES_CONF_DIR=/etc/ejabberd/modules
#.
#'
# vim: foldmarker=#',#. foldmethod=marker:
ejabberd-18.01/asn1/ 0000755 0002322 0002322 00000000000 13225664356 014505 5 ustar debalance debalance ejabberd-18.01/asn1/XmppAddr.asn1 0000644 0002322 0002322 00000000577 13225664356 017021 0 ustar debalance debalance XmppAddr { iso(1) identified-organization(3)
dod(6) internet(1) security(5) mechanisms(5) pkix(7)
id-on(8) id-on-xmppAddr(5) }
DEFINITIONS EXPLICIT TAGS ::=
BEGIN
id-on-xmppAddr OBJECT IDENTIFIER ::= { iso(1) identified-organization(3)
dod(6) internet(1) security(5) mechanisms(5) pkix(7)
id-on(8) 5 }
XmppAddr ::= UTF8String
END
ejabberd-18.01/COPYING 0000644 0002322 0002322 00000043324 13225664356 014704 0 ustar debalance debalance As a special exception, the authors give permission to link this program
with the OpenSSL library and distribute the resulting binary.
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
ejabberd-18.01/rebar.config.script 0000644 0002322 0002322 00000024411 13225664356 017432 0 ustar debalance debalance %%%----------------------------------------------------------------------
%%%
%%% ejabberd, Copyright (C) 2002-2017 ProcessOne
%%%
%%% This program is free software; you can redistribute it and/or
%%% modify it under the terms of the GNU General Public License as
%%% published by the Free Software Foundation; either version 2 of the
%%% License, or (at your option) any later version.
%%%
%%% This program is distributed in the hope that it will be useful,
%%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
%%% General Public License for more details.
%%%
%%% You should have received a copy of the GNU General Public License along
%%% with this program; if not, write to the Free Software Foundation, Inc.,
%%% 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
%%%
%%%----------------------------------------------------------------------
Vars = case file:consult(filename:join([filename:dirname(SCRIPT),"vars.config"])) of
{ok, Terms} ->
Terms;
_Err ->
[]
end ++ [{cflags, "-g -O2 -Wall"}, {cppflags, "-g -O2 -Wall"},
{ldflags, ""}, {system_deps, false}],
{cflags, CFlags} = lists:keyfind(cflags, 1, Vars),
{cppflags, CPPFlags} = lists:keyfind(cppflags, 1, Vars),
{ldflags, LDFlags} = lists:keyfind(ldflags, 1, Vars),
{system_deps, SystemDeps} = lists:keyfind(system_deps, 1, Vars),
GetCfg0 = fun(F, Cfg, [Key | Tail], Default) ->
Val = case lists:keyfind(Key, 1, Cfg) of
{Key, V1} -> V1;
false -> Default
end,
case Tail of
[] ->
Val;
_ ->
F(F, Val, Tail, Default)
end
end,
ModCfg0 = fun(F, Cfg, [Key | Tail], Op, Default) ->
{OldVal, PartCfg} = case lists:keytake(Key, 1, Cfg) of
{value, {_, V1}, V2} -> {V1, V2};
false -> {if Tail == [] -> Default; true -> [] end, Cfg}
end,
case Tail of
[] ->
[{Key, Op(OldVal)} | PartCfg];
_ ->
[{Key, F(F, OldVal, Tail, Op, Default)} | PartCfg]
end
end,
FilterConfig = fun(F, Cfg, [{Path, true, ModFun, Default} | Tail]) ->
F(F, ModCfg0(ModCfg0, Cfg, Path, ModFun, Default), Tail);
(F, Cfg, [{Path, SourcePath, true, ModFun, Default, SourceDefault} | Tail]) ->
SourceVal = GetCfg0(GetCfg0, Cfg, SourcePath, SourceDefault),
ModFun2 = fun(V) -> ModFun(V, SourceVal) end,
F(F, ModCfg0(ModCfg0, Cfg, Path, ModFun2, Default), Tail);
(F, Cfg, [_ | Tail]) ->
F(F, Cfg, Tail);
(_, Cfg, []) ->
Cfg
end,
IsRebar3 = case application:get_key(rebar, vsn) of
{ok, VSN} ->
[VSN1 | _] = string:tokens(VSN, "-"),
[Maj, _Min, _Patch] = string:tokens(VSN1, "."),
(list_to_integer(Maj) >= 3);
undefined ->
lists:keymember(mix, 1, application:loaded_applications())
end,
SysVer = erlang:system_info(otp_release),
ProcessSingleVar = fun(F, Var, Tail) ->
case F(F, [Var], []) of
[] -> Tail;
[Val] -> [Val | Tail]
end
end,
ProcessVars = fun(_F, [], Acc) ->
lists:reverse(Acc);
(F, [{Type, Ver, Value} | Tail], Acc) when
Type == if_version_above orelse
Type == if_version_below ->
SysVer = erlang:system_info(otp_release),
Include = if Type == if_version_above ->
SysVer > Ver;
true ->
SysVer < Ver
end,
if Include ->
F(F, Tail, ProcessSingleVar(F, Value, Acc));
true ->
F(F, Tail, Acc)
end;
(F, [{Type, Ver, Value, ElseValue} | Tail], Acc) when
Type == if_version_above orelse
Type == if_version_below ->
Include = if Type == if_version_above ->
SysVer > Ver;
true ->
SysVer < Ver
end,
if Include ->
F(F, Tail, ProcessSingleVar(F, Value, Acc));
true ->
F(F, Tail, ProcessSingleVar(F, ElseValue, Acc))
end;
(F, [{Type, Var, Value} | Tail], Acc) when
Type == if_var_true orelse
Type == if_var_false ->
Flag = Type == if_var_true,
case proplists:get_bool(Var, Vars) of
V when V == Flag ->
F(F, Tail, ProcessSingleVar(F, Value, Acc));
_ ->
F(F, Tail, Acc)
end;
(F, [{Type, Value} | Tail], Acc) when
Type == if_rebar3 orelse
Type == if_not_rebar3 ->
Flag = Type == if_rebar3,
case IsRebar3 == Flag of
true ->
F(F, Tail, ProcessSingleVar(F, Value, Acc));
_ ->
F(F, Tail, Acc)
end;
(F, [{Type, Var, Match, Value} | Tail], Acc) when
Type == if_var_match orelse
Type == if_var_no_match ->
case proplists:get_value(Var, Vars) of
V when V == Match ->
F(F, Tail, ProcessSingleVar(F, Value, Acc));
_ ->
F(F, Tail, Acc)
end;
(F, [{if_have_fun, MFA, Value} | Tail], Acc) ->
{Mod, Fun, Arity} = MFA,
code:ensure_loaded(Mod),
case erlang:function_exported(Mod, Fun, Arity) of
true ->
F(F, Tail, ProcessSingleVar(F, Value, Acc));
false ->
F(F, Tail, Acc)
end;
(F, [Other1 | Tail1], Acc) ->
F(F, Tail1, [F(F, Other1, []) | Acc]);
(F, Val, Acc) when is_tuple(Val) ->
list_to_tuple(F(F, tuple_to_list(Val), Acc));
(_F, Other2, _Acc) ->
Other2
end,
MaybeApply = fun(Val) when is_function(Val) ->
Val();
(Val) ->
Val
end,
MaybeApply2 = fun(Val, Arg) when is_function(Val) ->
Val(Arg);
(Val, _) ->
Val
end,
AppendStr = fun(Append) ->
fun("") ->
lists:flatten(MaybeApply(Append));
(Val) ->
lists:flatten([Val, " ", MaybeApply(Append)])
end
end,
AppendList = fun(Append) ->
fun(Val) ->
Val ++ MaybeApply(Append)
end
end,
AppendStr2 = fun(Append) ->
fun("", Arg) ->
lists:flatten(MaybeApply2(Append, Arg));
(Val, Arg) ->
lists:flatten([Val, " ", MaybeApply2(Append, Arg)])
end
end,
AppendList2 = fun(Append) ->
fun(Val, Arg) ->
Val ++ MaybeApply2(Append, Arg)
end
end,
Rebar3DepsFilter =
fun(DepsList) ->
lists:map(fun({DepName, _, {git, _, {tag, Version}}}) ->
{DepName, Version};
(Dep) ->
Dep
end, DepsList)
end,
GlobalDepsFilter =
fun(Deps) ->
DepNames = lists:map(fun({DepName, _, _}) -> DepName;
({DepName, _}) -> DepName
end, Deps),
lists:filtermap(fun(Dep) ->
case code:lib_dir(Dep) of
{error, _} ->
{true, "Unable to locate dep '" ++ atom_to_list(Dep) ++ "' in system deps."};
_ ->
false
end
end, DepNames)
end,
{ok, Cwd} = file:get_cwd(),
TestConfigFile = filename:join([Cwd, "test", "config.ctc"]),
TestConfig = case file:read_file_info(TestConfigFile) of
{ok, _} ->
[" -userconfig ct_config_plain ", TestConfigFile, " "];
_ ->
""
end,
ResolveDepPath = case {SystemDeps, IsRebar3} of
{true, _} ->
fun("deps/" ++ Rest) ->
Slash = string:str(Rest, "/"),
case code:lib_dir(string:sub_string(Rest, 1, Slash -1)) of
{error, _} -> Rest;
V -> V ++ string:sub_string(Rest, Slash)
end;
(Path) ->
Path
end;
{_, true} ->
fun("deps/" ++ Rest) ->
Slash = string:str(Rest, "/"),
"_build/default/lib/" ++
string:sub_string(Rest, 1, Slash - 1) ++
string:sub_string(Rest, Slash);
(Path) ->
Path
end;
_ ->
fun(P) ->
P
end
end,
CtParams = fun(CompileOpts) ->
["-ct_hooks cth_surefire ",
lists:map(fun({i, IncPath}) ->
[" -include ", filename:join([Cwd, ResolveDepPath(IncPath)])]
end, CompileOpts),
TestConfig]
end,
GenDepConfigureLine =
fun(DepPath, Flags) ->
["sh -c 'if test ! -f config.status -o ",
"../../config.status -nt config.status; ",
"then (",
"CFLAGS=\"", CFlags,"\" ",
"CPPFLAGS=\"", CPPFlags, "\" "
"LDFLAGS=\"", LDFlags, "\"",
" ./configure ", string:join(Flags, " "),
"); fi'"]
end,
GenDepsConfigure =
fun(Hooks) ->
lists:map(fun({Pkg, Flags}) ->
DepPath = ResolveDepPath("deps/" ++ Pkg ++ "/"),
{add, list_to_atom(Pkg), [{pre_hooks, {'compile',
lists:flatten(GenDepConfigureLine(DepPath, Flags))}}]}
end, Hooks)
end,
ProcessErlOpt = fun(Vals) ->
lists:map(
fun({i, Path}) ->
{i, ResolveDepPath(Path)};
(ErlOpt) ->
ErlOpt
end, Vals)
end,
ProcssXrefExclusions = fun(Items) ->
[{lists:flatten(["(XC - UC) || (XU - X - B ",
[[" - ", V] || V <- Items], ")"]),
[]}]
end,
ProcessFloatingDeps =
fun(Deps, FDeps) ->
lists:map(fun({DepName, _Ver, {git, Repo, _Commit}} = Dep) ->
case lists:member(DepName, FDeps) of
true ->
{DepName, ".*", {git, Repo}};
_ ->
Dep
end;
(Dep2) ->
Dep2
end, Deps)
end,
TravisPostHooks =
fun(true) ->
[{eunit, "echo '\n%%! -pa .eunit/ deps/coveralls/ebin\n" ++
"main(_)->{ok,F}=file:open(\"erlang.json\",[write])," ++
"io:fwrite(F,\"~s\",[coveralls:convert_file(" ++
"\".eunit/cover.coverdata\", \"" ++
os:getenv("TRAVIS_JOB_ID") ++
"\", \"travis-ci\",\"\")]).' > getcover.erl"},
{eunit, "escript ./getcover.erl"}];
(_) ->
[]
end,
Rules = [
{[provider_hooks], IsRebar3,
AppendList([{pre, [
{compile, {asn, compile}},
{clean, {asn, clean}}
]}]), []},
{[deps], os:getenv("TRAVIS") == "true",
AppendList([{coveralls, ".*", {git, "https://github.com/markusn/coveralls-erl.git", "master"}}]), []},
{[post_hooks], [cover_enabled], os:getenv("TRAVIS") == "true",
AppendList2(TravisPostHooks), [], false},
{[overrides], [post_hook_configure], SystemDeps == false,
AppendList2(GenDepsConfigure), [], []},
{[ct_extra_params], [eunit_compile_opts], true,
AppendStr2(CtParams), "", []},
{[erl_opts], true,
ProcessErlOpt, []},
{[xref_queries], [xref_exclusions], true,
AppendList2(ProcssXrefExclusions), [], []},
{[deps], [floating_deps], true,
ProcessFloatingDeps, [], []},
{[deps], IsRebar3,
Rebar3DepsFilter, []},
{[deps], SystemDeps /= false,
GlobalDepsFilter, []}
],
Config = [{plugin_dir, filename:join([filename:dirname(SCRIPT),"plugins"])}]++
FilterConfig(FilterConfig, ProcessVars(ProcessVars, CONFIG, []), Rules),
%io:format("ejabberd configuration:~n ~p~n", [Config]),
Config.
%% Local Variables:
%% mode: erlang
%% End:
%% vim: set filetype=erlang tabstop=8:
ejabberd-18.01/tools/ 0000755 0002322 0002322 00000000000 13225664356 015003 5 ustar debalance debalance ejabberd-18.01/tools/ejabberdctl.bc 0000644 0002322 0002322 00000005160 13225664356 017554 0 ustar debalance debalance #
# bash completion for ejabberdctl
#
get_help()
{
local COMMANDCACHE=/var/log/ejabberd/bash_completion_$RANDOM
ejabberdctl $CTLARGS help >$COMMANDCACHE
if [[ $? == 2 ]] ; then
ISRUNNING=1
runningcommands=`cat $COMMANDCACHE | grep "^ [a-z]" | awk '{print $1}' | xargs`
fi
rm $COMMANDCACHE
}
_ejabberdctl()
{
local cur prev
local ISRUNNING=0
local runningcommands
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
local startcoms="start debug live"
local startpars="--config-dir --config --ctl-config --logs --spool"
local i=1
local CTLARGS=""
while [ $i -lt $COMP_CWORD ] ; do
local PARAM="${COMP_WORDS[i]}"
i=$((i+1))
case $PARAM in
--*)
CTLARGS="--node ${COMP_WORDS[i]}"
i=$((i+1)) ;;
*) break ;;
esac
done
case "${prev##*/}" in
ejabberdctl)
# This clause matches even when calling `/sbin/ejabberdctl` thanks to the ##*/ in the case
get_help
COMPREPLY=($(compgen -W "--node ${startpars} ${startcoms} ${runningcommands}" -- $cur))
return 0
;;
start|live)
COMPREPLY=($(compgen -W "--node ${startpars}" -- $cur))
return 0
;;
debug)
COMPREPLY=($(compgen -W "--node" -- $cur))
return 0
;;
help)
get_help
COMPREPLY=($(compgen -W "${runningcommands}" -- $cur))
return 0
;;
--node)
RUNNINGNODES=`epmd -names | grep name | awk '{print $2"@localhost"}' | xargs`
COMPREPLY=($(compgen -W "$RUNNINGNODES" -- $cur))
return 0
;;
--config|--ctl-config)
_filedir '?(u)cfg'
return 0
;;
--config-dir|--logs|--spool)
_filedir
return 0
;;
*)
prev2="${COMP_WORDS[COMP_CWORD-2]}"
get_help
if [[ "$prev2" == --* ]]; then
COMPREPLY=($(compgen -W "--node ${startpars} ${startcoms} ${runningcommands}" -- $cur))
else
if [[ $ISRUNNING == 1 ]]; then
echo ""
ejabberdctl $CTLARGS help ${PARAM}
echo -n "${COMP_LINE}"
fi
fi
return 0
;;
esac
}
complete -F _ejabberdctl ejabberdctl
# Local variables:
# mode: shell-script
# sh-basic-offset: 4
# sh-indent-comment: t
# indent-tabs-mode: nil
# End:
# ex: ts=4 sw=4 et filetype=sh
ejabberd-18.01/tools/prepare-tr.sh 0000755 0002322 0002322 00000004603 13225664356 017426 0 ustar debalance debalance #!/bin/bash
# Frontend for ejabberd's extract-tr.sh
# How to create template files for a new language:
# NEWLANG=zh
# cp priv/msgs/ejabberd.pot priv/msgs/$NEWLANG.po
# echo \{\"\",\"\"\}. > priv/msgs/$NEWLANG.msg
# make translations
extract_lang_src2pot ()
{
./tools/extract-tr.sh ebin/ > priv/msgs/ejabberd.pot
}
extract_lang_popot2po ()
{
LANG_CODE=$1
PO_PATH=$MSGS_DIR/$LANG_CODE.po
POT_PATH=$MSGS_DIR/$PROJECT.pot
msgmerge $PO_PATH $POT_PATH >$PO_PATH.translate 2>/dev/null
mv $PO_PATH.translate $PO_PATH
}
extract_lang_po2msg ()
{
LANG_CODE=$1
PO_PATH=$LANG_CODE.po
MS_PATH=$PO_PATH.ms
MSGID_PATH=$PO_PATH.msgid
MSGSTR_PATH=$PO_PATH.msgstr
MSGS_PATH=$LANG_CODE.msg
cd $MSGS_DIR
# Check PO has correct ~
# Let's convert to C format so we can use msgfmt
PO_TEMP=$LANG_CODE.po.temp
cat $PO_PATH | sed 's/%/perc/g' | sed 's/~/%/g' | sed 's/#:.*/#, c-format/g' >$PO_TEMP
msgfmt $PO_TEMP --check-format
result=$?
rm $PO_TEMP
if [ $result -ne 0 ] ; then
exit 1
fi
msgattrib $PO_PATH --translated --no-fuzzy --no-obsolete --no-location --no-wrap | grep "^msg" | tail --lines=+3 >$MS_PATH
grep "^msgid" $PO_PATH.ms | sed 's/^msgid //g' >$MSGID_PATH
grep "^msgstr" $PO_PATH.ms | sed 's/^msgstr //g' >$MSGSTR_PATH
echo "%% -*- coding: latin-1 -*-" >$MSGS_PATH
paste $MSGID_PATH $MSGSTR_PATH --delimiter=, | awk '{print "{" $0 "}."}' | sort -g >>$MSGS_PATH
rm $MS_PATH
rm $MSGID_PATH
rm $MSGSTR_PATH
}
extract_lang_updateall ()
{
echo ""
echo "Generating POT..."
extract_lang_src2pot
cd $MSGS_DIR
echo ""
echo -e "File Missing (fuzzy) Language Last translator"
echo -e "---- ------- ------- -------- ---------------"
for i in $( ls *.msg ) ; do
LANG_CODE=${i%.msg}
echo -n $LANG_CODE | awk '{printf "%-6s", $1 }'
PO=$LANG_CODE.po
extract_lang_popot2po $LANG_CODE
extract_lang_po2msg $LANG_CODE
MISSING=`msgfmt --statistics $PO 2>&1 | awk '{printf "%5s", $4+$7 }'`
echo -n " $MISSING"
FUZZY=`msgfmt --statistics $PO 2>&1 | awk '{printf "%7s", $4 }'`
echo -n " $FUZZY"
LANGUAGE=`grep "X-Language:" $PO | sed 's/\"X-Language: //g' | sed 's/\\\\n\"//g' | awk '{printf "%-12s", $1}'`
echo -n " $LANGUAGE"
LASTAUTH=`grep "Last-Translator" $PO | sed 's/\"Last-Translator: //g' | sed 's/\\\\n\"//g'`
echo " $LASTAUTH"
done
echo ""
rm messages.mo
cd ..
}
EJA_DIR=`pwd`
PROJECT=ejabberd
MSGS_DIR=$EJA_DIR/priv/msgs
extract_lang_updateall
ejabberd-18.01/tools/jhbtest.pl 0000755 0002322 0002322 00000027552 13225664356 017021 0 ustar debalance debalance #!/usr/bin/perl -w
use strict; # har har
use constant ERR => 0;
use constant WARN => 1;
use constant INFO => 2;
use constant DEBUG => 3;
use constant RID => 31974;
### ### ### conf ### ### ###
my $BASE_ADDRESS = "http://localhost:5280/http-bind/";
my $JABBER_SERVER = "localhost";
my $RID = RID;
my $WAIT = 60;
my $USER = "tester";
my $UPW = "mysecret";
my $DEBUG = INFO;
### ### ### END conf ### ### ###
# create an agent we can use for our requests
use LWP::UserAgent;
my $ua = new LWP::UserAgent();
# create a tree parser to parse response content
use XML::Parser;
my $p = new XML::Parser(Style => 'Tree');
### ### ### subs ### ### ###
sub doSend() {
my $content = shift;
# create a request
my $req = new HTTP::Request(POST => $BASE_ADDRESS);
$req->content_type('text/xml; charset=utf-8');
$req->content($content);
debug(DEBUG,"<< Request\n".$req->as_string."<< END Request");
# send request
my $res = $ua->request($req);
debug(DEBUG,">> Response\n" . $res->as_string .">> END Response");
return $res;
}
# getChildEls
# used to strip enclosing body element
# PARAMS: @tree - tree style array from XML::Parser
# RETURN: @children - child elements of top level element
sub getChildEls
{
my $t = $_[0];
shift @{$t->[1]};
return @{$t->[1]};
}
sub debug
{
my $lvl = shift;
my $msg = shift;
return if ($DEBUG < $lvl);
my $prefix = "[";
$prefix .= "ERROR" if ($lvl == ERR);
$prefix .= "WARNING" if ($lvl == WARN);
$prefix .= "INFO" if ($lvl == INFO);
$prefix .= "DEBUG" if ($lvl == DEBUG);
$prefix .= "] ";
$msg =~ s/\n/\n$prefix/g;
print STDERR $prefix . $msg . "\n";
}
### ### ### main ### ### ###
$| = 1; # set streaming output
# no body
print "Sending some 'foo': ";
my $res = &doSend("foo");
if ($res->code == 400) {
print "OK.\n";
} else {
print "Failed!\n";
print $res->as_string, "\n";
}
# no body
print "Sending some '': ";
$res = &doSend("");
if ($res->code == 400) {
print "OK.\n";
} else {
print "Failed!\n";
print $res->as_string, "\n";
}
# empty body
print "Sending empty body: ";
$res = &doSend("");
if ($res->code == 400) {
print "OK.\n";
} else {
print "Failed!\n";
print $res->as_string, "\n";
}
# fake a sid
print "Sending wrong sid: ";
$res = &doSend("");
if ($res->code == 404) {
print "OK.\n";
} else {
print "Failed!\n";
print $res->as_string, "\n";
}
# forget to send 'to'
print "Missing 'to' attribute at session creation request: ";
$res = &doSend("");
if ($res->is_success && $res->content =~ /content =~/as_string, "\n";
}
# sending empty 'to' attribute
print "Empty 'to' attribute at session creation request: ";
$res = &doSend("");
if ($res->is_success && $res->content =~ /content =~/as_string, "\n";
}
# forget to send a rid
print "Missing 'rid' attribute at session creation request: ";
$res = &doSend("");
if ($res->code == 404) {
print "OK.\n";
} else {
print "Failed!\n";
print $res->as_string, "\n";
}
# trying to connect to non-existent domain
print "Connecting to non-existent domain: ";
$res = &doSend("");
if ($res->is_success && $res->content =~ /
content =~/as_string, "\n";
}
# trying to connect to non-existent jabber server
print "Connecting to non-existent jabber server: ";
$res = &doSend("content =~/content =~/as_string, "\n";
}
# connection to foreign server
#print "Connecting to foreign jabber server: ";
#$res = &doSend("content =~/as_string, "\n";
#}
my %sess;
sub getSess
{
$sess{rid} = RID; # a rid to start
$res = &doSend("$USER");
my @els = (&getChildEls($p->parse($res->content)));
unless ($els[0] eq 'iq' && $els[1]->[0]->{'type'} eq 'result') {
debug(ERR, $res->content);
return 0;
}
# send auth
$sess{rid}++;
$res = &doSend("$USERtest$UPW");
@els = (&getChildEls($p->parse($res->content)));
unless ($els[0] eq 'iq' && $els[1]->[0]->{'type'} eq 'result') {
debug(ERR, $res->content);
return 0;
}
return 1;
}
print "Authenticating: ";
if (&doAuth()) {
print "OK.\n";
} else {
print "FAILED!\n";
debug(ERR, "Aborting.");
exit(1);
}
sub doPoll
{
$sess{rid}++;
return &doSend("");
debug(INFO, $res->content);
# send presence
print "sending presence\n";
$sess{rid}++;
$res = &doSend("");
debug(INFO, $res->content);
# sending bullshit
print "sending bullshit\n";
$sess{rid}++;
$res = &doSend("sending bullshit");
debug(INFO, $res->content);
# send presence
print "sending xa presence\n";
$sess{rid}++;
$res = &doSend("xa");
debug(INFO, $res->content);
# disconnect
sleep 3;
print "logout\n";
$sess{rid}++;
$res = &doSend("");
debug(INFO, $res->content);
print "Checking if session terminated: ";
$res = &doPoll();
if ($res->code != 404) {
print "FAILED!\n";
debug(ERR, "Aborting.");
exit(1);
}
print "OK.\n";
ejabberd-18.01/tools/hook_deps.sh 0000755 0002322 0002322 00000027046 13225664356 017326 0 ustar debalance debalance #!/usr/bin/env escript
%% -*- erlang -*-
%%! -pa ebin
-record(state, {run_hooks = dict:new(),
run_fold_hooks = dict:new(),
hooked_funs = dict:new(),
mfas = dict:new(),
specs = dict:new(),
module :: module(),
file :: filename:filename()}).
main([Dir]) ->
State =
filelib:fold_files(
Dir, ".+\.[eh]rl\$", false,
fun(FileIn, Res) ->
case get_forms(FileIn) of
{ok, Forms} ->
Tree = erl_syntax:form_list(Forms),
Mod = list_to_atom(filename:rootname(filename:basename(FileIn))),
Acc0 = analyze_form(Tree, Res#state{module = Mod, file = FileIn}),
erl_syntax_lib:fold(
fun(Form, Acc) ->
case erl_syntax:type(Form) of
application ->
case erl_syntax_lib:analyze_application(Form) of
{ejabberd_hooks, {run, N}}
when N == 2; N == 3 ->
analyze_run_hook(Form, Acc);
{ejabberd_hooks, {run_fold, N}}
when N == 3; N == 4 ->
analyze_run_fold_hook(Form, Acc);
{ejabberd_hooks, {add, N}}
when N == 4; N == 5 ->
analyze_run_fun(Form, Acc);
{gen_iq_handler, {add_iq_handler, 6}} ->
analyze_iq_handler(Form, Acc);
_ ->
Acc
end;
attribute ->
case catch erl_syntax_lib:analyze_attribute(Form) of
{spec, _} ->
analyze_type_spec(Form, Acc);
_ ->
Acc
end;
_ ->
Acc
end
end, Acc0, Tree);
_Err ->
Res
end
end, #state{}),
report_orphaned_funs(State),
RunDeps = build_deps(State#state.run_hooks, State#state.hooked_funs),
RunFoldDeps = build_deps(State#state.run_fold_hooks, State#state.hooked_funs),
emit_module(RunDeps, RunFoldDeps, State#state.specs, Dir, hooks_type_test).
analyze_form(_Form, State) ->
%% case catch erl_syntax_lib:analyze_forms(Form) of
%% Props when is_list(Props) ->
%% M = State#state.module,
%% MFAs = lists:foldl(
%% fun({F, A}, Acc) ->
%% dict:append({M, F}, A, Acc)
%% end, State#state.mfas,
%% proplists:get_value(functions, Props, [])),
%% State#state{mfas = MFAs};
%% _ ->
%% State
%% end.
State.
analyze_run_hook(Form, State) ->
[Hook|Tail] = erl_syntax:application_arguments(Form),
case atom_value(Hook, State) of
undefined ->
State;
HookName ->
Args = case Tail of
[_Host, Args0] -> Args0;
[Args0] ->
Args0
end,
Arity = erl_syntax:list_length(Args),
Hooks = dict:store({HookName, Arity},
{State#state.file, erl_syntax:get_pos(Hook)},
State#state.run_hooks),
State#state{run_hooks = Hooks}
end.
analyze_run_fold_hook(Form, State) ->
[Hook|Tail] = erl_syntax:application_arguments(Form),
case atom_value(Hook, State) of
undefined ->
State;
HookName ->
Args = case Tail of
[_Host, _Val, Args0] -> Args0;
[_Val, Args0] -> Args0
end,
Arity = erl_syntax:list_length(Args) + 1,
Hooks = dict:store({HookName, Arity},
{State#state.file, erl_syntax:get_pos(Form)},
State#state.run_fold_hooks),
State#state{run_fold_hooks = Hooks}
end.
analyze_run_fun(Form, State) ->
[Hook|Tail] = erl_syntax:application_arguments(Form),
case atom_value(Hook, State) of
undefined ->
State;
HookName ->
{Module, Fun, Seq} = case Tail of
[_Host, M, F, S] ->
{M, F, S};
[M, F, S] ->
{M, F, S}
end,
ModName = module_name(Module, State),
FunName = atom_value(Fun, State),
if ModName /= undefined, FunName /= undefined ->
Funs = dict:append(
HookName,
{ModName, FunName, integer_value(Seq, State),
{State#state.file, erl_syntax:get_pos(Form)}},
State#state.hooked_funs),
State#state{hooked_funs = Funs};
true ->
State
end
end.
analyze_iq_handler(Form, State) ->
[_Component, _Host, _NS, Module, Function, _IQDisc] =
erl_syntax:application_arguments(Form),
Mod = module_name(Module, State),
Fun = atom_value(Function, State),
if Mod /= undefined, Fun /= undefined ->
code:ensure_loaded(Mod),
case erlang:function_exported(Mod, Fun, 1) of
false ->
log("~s:~p: Error: function ~s:~s/1 is registered "
"as iq handler, but is not exported~n",
[State#state.file, erl_syntax:get_pos(Form),
Mod, Fun]);
true ->
ok
end;
true ->
ok
end,
State.
analyze_type_spec(Form, State) ->
case catch erl_syntax:revert(Form) of
{attribute, _, spec, {{F, A}, _}} ->
Specs = dict:store({State#state.module, F, A},
{Form, State#state.file},
State#state.specs),
State#state{specs = Specs};
_ ->
State
end.
build_deps(Hooks, Hooked) ->
dict:fold(
fun({Hook, Arity}, {_File, _LineNo} = Meta, Deps) ->
case dict:find(Hook, Hooked) of
{ok, Funs} ->
ExportedFuns =
lists:flatmap(
fun({M, F, Seq, {FunFile, FunLineNo} = FunMeta}) ->
code:ensure_loaded(M),
case erlang:function_exported(M, F, Arity) of
false ->
log("~s:~p: Error: function ~s:~s/~p "
"is hooked on ~s/~p, but is not "
"exported~n",
[FunFile, FunLineNo, M, F,
Arity, Hook, Arity]),
[];
true ->
[{{M, F, Arity}, Seq, FunMeta}]
end
end, Funs),
dict:append_list({Hook, Arity, Meta}, ExportedFuns, Deps);
error ->
%% log("~s:~p: Warning: hook ~p/~p is unused~n",
%% [_File, _LineNo, Hook, Arity]),
dict:append_list({Hook, Arity, Meta}, [], Deps)
end
end, dict:new(), Hooks).
report_orphaned_funs(State) ->
dict:map(
fun(Hook, Funs) ->
lists:foreach(
fun({M, F, _, {File, Line}}) ->
case get_fun_arities(M, F, State) of
[] ->
log("~s:~p: Error: function ~s:~s is "
"hooked on hook ~s, but is not exported~n",
[File, Line, M, F, Hook]);
Arities ->
case lists:any(
fun(Arity) ->
dict:is_key({Hook, Arity},
State#state.run_hooks) orelse
dict:is_key({Hook, Arity},
State#state.run_fold_hooks);
(_) ->
false
end, Arities) of
false ->
Arity = hd(Arities),
log("~s:~p: Error: function ~s:~s/~p is hooked"
" on non-existent hook ~s/~p~n",
[File, Line, M, F, Arity, Hook, Arity]);
true ->
ok
end
end
end, Funs)
end, State#state.hooked_funs).
get_fun_arities(Mod, Fun, _State) ->
proplists:get_all_values(Fun, Mod:module_info(exports)).
module_name(Form, State) ->
try
Name = erl_syntax:macro_name(Form),
'MODULE' = erl_syntax:variable_name(Name),
State#state.module
catch _:_ ->
atom_value(Form, State)
end.
atom_value(Form, State) ->
case erl_syntax:type(Form) of
atom ->
erl_syntax:atom_value(Form);
_ ->
log("~s:~p: Warning: not an atom: ~s~n",
[State#state.file,
erl_syntax:get_pos(Form),
erl_prettypr:format(Form)]),
undefined
end.
integer_value(Form, State) ->
case erl_syntax:type(Form) of
integer ->
erl_syntax:integer_value(Form);
_ ->
log("~s:~p: Warning: not an integer: ~s~n",
[State#state.file,
erl_syntax:get_pos(Form),
erl_prettypr:format(Form)]),
0
end.
emit_module(RunDeps, RunFoldDeps, Specs, Dir, Module) ->
File = filename:join([Dir, Module]) ++ ".erl",
try
{ok, Fd} = file:open(File, [write]),
write(Fd, "-module(~s).~n~n", [Module]),
emit_export(Fd, RunDeps, "run hooks"),
emit_export(Fd, RunFoldDeps, "run_fold hooks"),
emit_run_hooks(Fd, RunDeps, Specs),
emit_run_fold_hooks(Fd, RunFoldDeps, Specs),
file:close(Fd),
log("Module written to file ~s~n", [File])
catch _:{badmatch, {error, Reason}} ->
log("writing to ~s failed: ~s", [File, file:format_error(Reason)])
end.
emit_run_hooks(Fd, Deps, Specs) ->
DepsList = lists:sort(dict:to_list(Deps)),
lists:foreach(
fun({{Hook, Arity, {File, LineNo}}, []}) ->
Args = lists:duplicate(Arity, "_"),
write(Fd, "%% called at ~s:~p~n", [File, LineNo]),
write(Fd, "~s(~s) -> ok.~n~n", [Hook, string:join(Args, ", ")]);
({{Hook, Arity, {File, LineNo}}, Funs}) ->
emit_specs(Fd, Funs, Specs),
write(Fd, "%% called at ~s:~p~n", [File, LineNo]),
Args = string:join(
[[N] || N <- lists:sublist(lists:seq($A, $Z), Arity)],
", "),
write(Fd, "~s(~s) ->~n ", [Hook, Args]),
Calls = [io_lib:format("~s:~s(~s)", [Mod, Fun, Args])
|| {{Mod, Fun, _}, _Seq, _} <- lists:keysort(2, Funs)],
write(Fd, "~s.~n~n", [string:join(Calls, ",\n ")])
end, DepsList).
emit_run_fold_hooks(Fd, Deps, Specs) ->
DepsList = lists:sort(dict:to_list(Deps)),
lists:foreach(
fun({{Hook, Arity, {File, LineNo}}, []}) ->
write(Fd, "%% called at ~s:~p~n", [File, LineNo]),
Args = ["Acc"|lists:duplicate(Arity - 1, "_")],
write(Fd, "~s(~s) -> Acc.~n~n", [Hook, string:join(Args, ", ")]);
({{Hook, Arity, {File, LineNo}}, Funs}) ->
emit_specs(Fd, Funs, Specs),
write(Fd, "%% called at ~s:~p~n", [File, LineNo]),
Args = [[N] || N <- lists:sublist(lists:seq($A, $Z), Arity - 1)],
write(Fd, "~s(~s) ->~n ", [Hook, string:join(["Acc0"|Args], ", ")]),
{Calls, _} = lists:mapfoldl(
fun({{Mod, Fun, _}, _Seq, _}, N) ->
Args1 = ["Acc" ++ integer_to_list(N)|Args],
{io_lib:format("Acc~p = ~s:~s(~s)",
[N+1, Mod, Fun,
string:join(Args1, ", ")]),
N + 1}
end, 0, lists:keysort(2, Funs)),
write(Fd, "~s,~n", [string:join(Calls, ",\n ")]),
write(Fd, " Acc~p.~n~n", [length(Funs)])
end, DepsList).
emit_export(Fd, Deps, Comment) ->
DepsList = lists:sort(dict:to_list(Deps)),
Exports = lists:map(
fun({{Hook, Arity, _}, _}) ->
io_lib:format("~s/~p", [Hook, Arity])
end, DepsList),
write(Fd, "%% ~s~n-export([~s]).~n~n",
[Comment, string:join(Exports, ",\n ")]).
emit_specs(Fd, Funs, Specs) ->
lists:foreach(
fun({{M, _, _} = MFA, _, _}) ->
case dict:find(MFA, Specs) of
{ok, {Form, _File}} ->
Lines = string:tokens(erl_syntax:get_ann(Form), "\n"),
lists:foreach(
fun("%" ++ _) ->
ok;
("-spec" ++ Spec) ->
write(Fd, "%% -spec ~p:~s~n",
[M, string:strip(Spec, left)]);
(Line) ->
write(Fd, "%% ~s~n", [Line])
end, Lines);
error ->
ok
end
end, lists:keysort(2, Funs)).
get_forms(Path) ->
case file:open(Path, [read]) of
{ok, Fd} ->
parse(Path, Fd, 1, []);
Err ->
Err
end.
parse(Path, Fd, Line, Acc) ->
{ok, Pos} = file:position(Fd, cur),
case epp_dodger:parse_form(Fd, Line) of
{ok, Form, NewLine} ->
{ok, NewPos} = file:position(Fd, cur),
{ok, RawForm} = file:pread(Fd, Pos, NewPos - Pos),
file:position(Fd, {bof, NewPos}),
AnnForm = erl_syntax:set_ann(Form, RawForm),
parse(Path, Fd, NewLine, [AnnForm|Acc]);
{eof, _} ->
{ok, NewPos} = file:position(Fd, cur),
if NewPos > Pos ->
{ok, RawForm} = file:pread(Fd, Pos, NewPos - Pos),
Form = erl_syntax:text(""),
AnnForm = erl_syntax:set_ann(Form, RawForm),
{ok, lists:reverse([AnnForm|Acc])};
true ->
{ok, lists:reverse(Acc)}
end;
{error, {_, _, ErrDesc}, LineNo} = Err ->
log("~s:~p: Error: ~s~n",
[Path, LineNo, erl_parse:format_error(ErrDesc)]),
Err
end.
log(Format, Args) ->
io:format(standard_io, Format, Args).
write(Fd, Format, Args) ->
file:write(Fd, io_lib:format(Format, Args)).
ejabberd-18.01/tools/extract-tr.sh 0000755 0002322 0002322 00000017171 13225664356 017446 0 ustar debalance debalance #!/usr/bin/env escript
%% -*- erlang -*-
%%! -pa ebin
main([Dir]) ->
Txts =
filelib:fold_files(
Dir, ".+\.beam\$", false,
fun(BeamFile, Res) ->
Mod = mod(BeamFile),
ErlFile = filename:join("src", Mod ++ ".erl"),
case get_forms(BeamFile, ErlFile) of
{ok, BeamForms, ErlForms} ->
process_forms(BeamForms, Mod, application) ++
process_forms(ErlForms, Mod, macro) ++ Res;
_Err ->
Res
end
end, []),
Dict = lists:foldl(
fun({B, Meta}, Acc) ->
dict:update(
binary_to_list(B),
fun(OldMeta) ->
lists:usort([Meta|OldMeta])
end,
[Meta], Acc)
end, dict:new(), Txts),
generate_pot(Dict).
process_forms(Forms, Mod, Type) ->
Tree = erl_syntax:form_list(Forms),
erl_syntax_lib:fold_subtrees(
fun(Form, Acc) ->
case erl_syntax:type(Form) of
function ->
case map(Form, Mod, Type) of
[] ->
Acc;
Vars ->
Vars ++ Acc
end;
_ ->
Acc
end
end, [], Tree).
map(Tree, Mod, Type) ->
Vars = erl_syntax_lib:fold(
fun(Form, Acc) ->
case erl_syntax:type(Form) of
Type when Type == application ->
analyze_app(Form, Mod) ++ Acc;
Type when Type == macro ->
analyze_macro(Form, Mod) ++ Acc;
_ ->
Acc
end
end, [], Tree),
Bins = lists:flatmap(
fun({Var, Pos}) when is_atom(Var) ->
Res = erl_syntax_lib:fold(
fun(Form, Acc) ->
case process_match_expr(
Form, Var, Mod) of
{ok, Binary, NewPos} ->
[{Binary, NewPos}|Acc];
error ->
Acc
end
end, [], Tree),
case Res of
[] ->
log("~s:~p: unresolved variable: ~s~n",
[Mod, Pos, Var]);
_ ->
ok
end,
Res;
({Var, Pos}) when is_binary(Var) ->
[{Var, Pos}]
end, lists:usort(Vars)),
[{B, {Mod, Pos}} || {B, Pos} <- Bins, B /= <<"">>].
process_match_expr(Form, Var, Mod) ->
case erl_syntax:type(Form) of
match_expr ->
Pattern = erl_syntax:match_expr_pattern(Form),
Body = erl_syntax:match_expr_body(Form),
{V, Expr} =
case {erl_syntax:type(Pattern), erl_syntax:type(Body)} of
{variable, _} ->
{erl_syntax:variable_name(Pattern), Body};
{_, variable} ->
{erl_syntax:variable_name(Body), Pattern};
_ ->
{'', none}
end,
Text = maybe_extract_tuple(Expr),
if V == Var ->
Pos = erl_syntax:get_pos(Text),
try {ok, erl_syntax:concrete(Text), Pos}
catch _:_ ->
case catch erl_syntax_lib:analyze_application(Text) of
{_M, {Fn, 1}} when Fn == format_error;
Fn == io_format_error ->
error;
_ ->
log("~s:~p: not a binary: ~s~n",
[Mod, Pos, erl_prettypr:format(Text)]),
{ok, <<>>, Pos}
end
end;
true ->
error
end;
_ ->
error
end.
maybe_extract_tuple(none) ->
none;
maybe_extract_tuple(Form) ->
try
tuple = erl_syntax:type(Form),
[Text, _] = erl_syntax:tuple_elements(Form),
Text
catch _:{badmatch, _} ->
Form
end.
analyze_app(Form, Mod) ->
try
{M, {F, A}} = erl_syntax_lib:analyze_application(Form),
Args = erl_syntax:application_arguments(Form),
Txt = case {M, atom_to_list(F), A, Args} of
{xmpp, "err_" ++ _, 2, [T|_]} -> T;
{xmpp, "serr_" ++ _, 2, [T|_]} -> T;
{xmpp, "mk_text", 2, [T|_]} -> T;
{translate, "translate", 2, [_,T|_]} -> T
end,
Pos = erl_syntax:get_pos(Txt),
case erl_syntax:type(Txt) of
binary ->
try [{erl_syntax:concrete(Txt), Pos}]
catch _:_ ->
Pos = erl_syntax:get_pos(Txt),
log("~s:~p: not a binary: ~s~n",
[Mod, Pos, erl_prettypr:format(Txt)]),
[]
end;
variable ->
[{erl_syntax:variable_name(Txt), Pos}];
application ->
Vars = sets:to_list(erl_syntax_lib:variables(Txt)),
case Vars of
[Var] ->
[{Var, Pos}];
[_|_] ->
log("Too many variables: ~p~n", [Vars]),
[];
[] ->
[]
end;
_ ->
[]
end
catch _:{badmatch, _} ->
[];
_:{case_clause, _} ->
[]
end.
analyze_macro(Form, Mod) ->
try
Name = erl_syntax:macro_name(Form),
variable = erl_syntax:type(Name),
'T' = erl_syntax:variable_name(Name),
[Txt] = erl_syntax:macro_arguments(Form),
string = erl_syntax:type(Txt),
Pos = erl_syntax:get_pos(Txt),
try [{list_to_binary(erl_syntax:string_value(Txt)), Pos}]
catch _:_ ->
log("~s:~p: not a binary: ~s~n",
[Mod, Pos, erl_prettypr:format(Txt)]),
[]
end
catch _:{badmatch, _} ->
[]
end.
generate_pot(Dict) ->
io:format("~s~n~n", [pot_header()]),
lists:foreach(
fun({Msg, Location}) ->
S1 = format_location(Location),
S2 = format_msg(Msg),
io:format("~smsgstr \"\"~n~n", [S1 ++ S2])
end, lists:keysort(1, dict:to_list(Dict))).
format_location([A, B, C|T]) ->
format_location_list([A,B,C]) ++ format_location(T);
format_location([A, B|T]) ->
format_location_list([A,B]) ++ format_location(T);
format_location([A|T]) ->
format_location_list([A]) ++ format_location(T);
format_location([]) ->
"".
format_location_list(L) ->
"#: " ++ string:join(
lists:map(
fun({File, Pos}) ->
io_lib:format("~s:~B", [File, Pos])
end, L),
" ") ++ io_lib:nl().
format_msg(Bin) ->
io_lib:format("msgid \"~s\"~n", [escape(Bin)]).
escape(Bin) ->
lists:map(
fun($") -> "\\\"";
(C) -> C
end, binary_to_list(iolist_to_binary(Bin))).
pot_header() ->
string:join(
["msgid \"\"",
"msgstr \"\"",
"\"Project-Id-Version: 15.11.127\\n\"",
"\"X-Language: Language Name\\n\"",
"\"Last-Translator: Translator name and contact method\\n\"",
"\"MIME-Version: 1.0\\n\"",
"\"Content-Type: text/plain; charset=UTF-8\\n\"",
"\"Content-Transfer-Encoding: 8bit\\n\""],
io_lib:nl()).
mod(Path) ->
filename:rootname(filename:basename(Path)).
log(Format, Args) ->
io:format(standard_error, Format, Args).
get_forms(BeamFile, ErlFile) ->
try
{ok, BeamForms} = get_beam_forms(BeamFile),
{ok, ErlForms} = get_erl_forms(ErlFile),
{ok, BeamForms, ErlForms}
catch _:{badmatch, error} ->
error
end.
get_beam_forms(File) ->
case beam_lib:chunks(File, [abstract_code]) of
{ok, {_, List}} ->
case lists:keyfind(abstract_code, 1, List) of
{abstract_code, {raw_abstract_v1, Abstr}} ->
{ok, Abstr};
_Err ->
log("failed to get abstract code from ~s~n", [File]),
error
end;
Err ->
log("failed to read chunks from ~s: ~p~n", [File, Err]),
error
end.
get_erl_forms(Path) ->
case file:open(Path, [read]) of
{ok, Fd} ->
parse(Path, Fd, 1, []);
{error, Why} ->
log("failed to read ~s: ~s~n", [Path, file:format_error(Why)]),
error
end.
parse(Path, Fd, Line, Acc) ->
{ok, Pos} = file:position(Fd, cur),
case epp_dodger:parse_form(Fd, Line) of
{ok, Form, NewLine} ->
{ok, NewPos} = file:position(Fd, cur),
{ok, RawForm} = file:pread(Fd, Pos, NewPos - Pos),
file:position(Fd, {bof, NewPos}),
AnnForm = erl_syntax:set_ann(Form, RawForm),
parse(Path, Fd, NewLine, [AnnForm|Acc]);
{eof, _} ->
{ok, NewPos} = file:position(Fd, cur),
if NewPos > Pos ->
{ok, RawForm} = file:pread(Fd, Pos, NewPos - Pos),
Form = erl_syntax:text(""),
AnnForm = erl_syntax:set_ann(Form, RawForm),
{ok, lists:reverse([AnnForm|Acc])};
true ->
{ok, lists:reverse(Acc)}
end;
Err ->
log("failed to parse ~s: ~p~n", [Path, Err]),
error
end.
ejabberd-18.01/tools/captcha.sh 0000755 0002322 0002322 00000004135 13225664356 016750 0 ustar debalance debalance #!/bin/sh
INPUT=$1
if test -n ${BASH_VERSION:-''} ; then
get_random ()
{
R=$RANDOM
}
else
for n in `od -A n -t u2 -N 48 /dev/urandom`; do RL="$RL$n "; done
get_random ()
{
R=${RL%% *}
RL=${RL#* }
}
fi
get_random
WAVE1_AMPLITUDE=$((2 + $R % 5))
get_random
WAVE1_LENGTH=$((50 + $R % 25))
get_random
WAVE2_AMPLITUDE=$((2 + $R % 5))
get_random
WAVE2_LENGTH=$((50 + $R % 25))
get_random
WAVE3_AMPLITUDE=$((2 + $R % 5))
get_random
WAVE3_LENGTH=$((50 + $R % 25))
get_random
W1_LINE_START_Y=$((10 + $R % 40))
get_random
W1_LINE_STOP_Y=$((10 + $R % 40))
get_random
W2_LINE_START_Y=$((10 + $R % 40))
get_random
W2_LINE_STOP_Y=$((10 + $R % 40))
get_random
W3_LINE_START_Y=$((10 + $R % 40))
get_random
W3_LINE_STOP_Y=$((10 + $R % 40))
get_random
B1_LINE_START_Y=$(($R % 40))
get_random
B1_LINE_STOP_Y=$(($R % 40))
get_random
B2_LINE_START_Y=$(($R % 40))
get_random
B2_LINE_STOP_Y=$(($R % 40))
#B3_LINE_START_Y=$(($R % 40))
#B3_LINE_STOP_Y=$(($R % 40))
get_random
B1_LINE_START_X=$(($R % 20))
get_random
B1_LINE_STOP_X=$((100 + $R % 40))
get_random
B2_LINE_START_X=$(($R % 20))
get_random
B2_LINE_STOP_X=$((100 + $R % 40))
#B3_LINE_START_X=$(($R % 20))
#B3_LINE_STOP_X=$((100 + $R % 40))
get_random
ROLL_X=$(($R % 40))
convert -size 180x60 xc:none -pointsize 40 \
\( -clone 0 -fill white \
-stroke black -strokewidth 4 -annotate +0+40 "$INPUT" \
-stroke white -strokewidth 2 -annotate +0+40 "$INPUT" \
-roll +$ROLL_X+0 \
-wave "$WAVE1_AMPLITUDE"x"$WAVE1_LENGTH" \
-roll -$ROLL_X+0 \) \
\( -clone 0 -stroke black \
-strokewidth 1 -draw \
"line $B1_LINE_START_X,$B1_LINE_START_Y $B1_LINE_STOP_X,$B1_LINE_STOP_Y" \
-strokewidth 1 -draw \
"line $B2_LINE_START_X,$B2_LINE_START_Y $B2_LINE_STOP_X,$B2_LINE_STOP_Y" \
-wave "$WAVE2_AMPLITUDE"x"$WAVE2_LENGTH" \) \
\( -clone 0 -stroke white \
-strokewidth 2 -draw "line 0,$W1_LINE_START_Y 140,$W1_LINE_STOP_Y" \
-strokewidth 2 -draw "line 0,$W2_LINE_START_Y 140,$W2_LINE_STOP_Y" \
-strokewidth 2 -draw "line 0,$W3_LINE_START_Y 140,$W3_LINE_STOP_Y" \
-wave "$WAVE3_AMPLITUDE"x"$WAVE3_LENGTH" \) \
-flatten -crop 140x60 +repage -quality 90 -depth 8 png:-
ejabberd-18.01/tools/update-deps-releases.pl 0000755 0002322 0002322 00000035721 13225664356 021367 0 ustar debalance debalance #!/usr/bin/perl
use v5.10;
use strict;
use warnings;
use File::Slurp qw(slurp write_file);
use File::stat;
use File::Touch;
use Data::Dumper qw(Dumper);
use Carp;
use Term::ANSIColor;
use Term::ReadKey;
use List::Util qw(first);
use Clone qw(clone);
sub get_deps {
my ($config, %fdeps) = @_;
my %deps;
return { } unless $config =~ /\{\s*deps\s*,\s*\[(.*?)\]/s;
my $sdeps = $1;
while ($sdeps =~ /\{\s* (\w+) \s*,\s* ".*?" \s*,\s* \{\s*git \s*,\s* "(.*?)" \s*,\s*
(?:
(?:{\s*tag \s*,\s* "(.*?)") |
"(.*?)" |
( \{ (?: (?-1) | [^{}]+ )+ \} ) )/sgx) {
next unless not %fdeps or exists $fdeps{$1};
$deps{$1} = { repo => $2, commit => $3 || $4 };
}
return \%deps;
}
my (%info_updates, %top_deps_updates, %sub_deps_updates, @operations);
my $epoch = 1;
sub top_deps {
state %deps;
state $my_epoch = $epoch;
if (not %deps or $my_epoch != $epoch) {
$my_epoch = $epoch;
my $config = slurp "rebar.config";
croak "Unable to extract floating_deps" unless $config =~ /\{floating_deps, \[(.*?)\]/s;
my $fdeps = $1;
$fdeps =~ s/\s*//g;
my %fdeps = map { $_ => 1 } split /,/, $fdeps;
%deps = %{get_deps($config, %fdeps)};
}
return {%deps, %top_deps_updates};
}
sub update_deps_repos {
my ($force) = @_;
my $deps = top_deps();
$epoch++;
mkdir(".deps-update") unless -d ".deps-update";
for my $dep (keys %{$deps}) {
my $dd = ".deps-update/$dep";
if (not -d $dd) {
say "Downloading $dep...";
my $repo = $deps->{$dep}->{repo};
$repo =~ s!^https?://github.com/!git\@github.com:!;
system("git", "-C", ".deps-update", "clone", $repo);
} elsif (time() - stat($dd)->mtime > 24 * 60 * 60 or $force) {
say "Updating $dep...";
system("git", "-C", $dd, "pull");
touch($dd)
}
}
}
sub sub_deps {
state %sub_deps;
state $my_epoch = $epoch;
if (not %sub_deps or $my_epoch != $epoch) {
$my_epoch = $epoch;
my $deps = top_deps();
for my $dep (keys %{$deps}) {
my $rc = ".deps-update/$dep/rebar.config";
$sub_deps{$dep} = { };
next unless -f $rc;
$sub_deps{$dep} = get_deps(scalar(slurp($rc)));
}
}
return {%sub_deps, %sub_deps_updates};
}
sub rev_deps_helper {
my ($rev_deps, $dep) = @_;
if (not exists $rev_deps->{$dep}->{indirect}) {
my %deps = %{$rev_deps->{$dep}->{direct} || {}};
for (keys %{$rev_deps->{$dep}->{direct}}) {
%deps = (%deps, %{rev_deps_helper($rev_deps, $_)});
}
$rev_deps->{$dep}->{indirect} = \%deps;
}
return $rev_deps->{$dep}->{indirect};
}
sub rev_deps {
state %rev_deps;
state $deps_epoch = $epoch;
if (not %rev_deps or $deps_epoch != $epoch) {
$deps_epoch = $epoch;
my $sub_deps = sub_deps();
for my $dep (keys %$sub_deps) {
$rev_deps{$_}->{direct}->{$dep} = 1 for keys %{$sub_deps->{$dep}};
}
for my $dep (keys %$sub_deps) {
$rev_deps{$dep}->{indirect} = rev_deps_helper(\%rev_deps, $dep);
}
}
return \%rev_deps;
}
sub update_changelog {
my ($dep, $version, @reasons) = @_;
my $cl = ".deps-update/$dep/CHANGELOG.md";
return if not -f $cl;
my $reason = join "\n", map {"* $_"} @reasons;
my $content = slurp($cl);
if (not $content =~ /^# Version $version/) {
$content = "# Version $version\n\n$reason\n\n$content";
} else {
$content =~ s/(# Version $version\n\n)/$1$reason\n/;
}
write_file($cl, $content);
}
sub edit_changelog {
my ($dep, $version) = @_;
my $cl = ".deps-update/$dep/CHANGELOG.md";
return if not -f $cl;
my $top_deps = top_deps();
my $git_info = deps_git_info();
say color("red"), "$dep", color("reset"), " ($top_deps->{$dep}->{commit}):";
say " $_" for @{$git_info->{$dep}->{new_commits}};
say "";
my $content = slurp($cl);
my $old_content = $content;
if (not $content =~ /^# Version $version/) {
$content = "# Version $version\n\n* \n\n$content";
} else {
$content =~ s/(# Version $version\n\n)/$1* \n/;
}
write_file($cl, $content);
system("$ENV{EDITOR} $cl");
my $new_content = slurp($cl);
if ($new_content eq $content) {
write_file($cl, $old_content);
} else {
system("git", "-C", ".deps-update/$dep", "commit", "-a", "-m", "Update changelog");
}
}
sub update_app_src {
my ($dep, $version) = @_;
my $app = ".deps-update/$dep/src/$dep.app.src";
return if not -f $app;
my $content = slurp($app);
$content =~ s/({\s*vsn\s*,\s*)".*"/$1"$version"/;
write_file($app, $content);
}
sub update_deps_versions {
my ($config_path, %deps) = @_;
my $config = slurp $config_path;
for (keys %deps) {
$config =~ s/(\{\s*$_\s*,\s*".*?"\s*,\s*\{\s*git\s*,\s*".*?"\s*,\s*)(?:{\s*tag\s*,\s*"(.*?)"\s*}|"(.*?)")/$1\{tag, "$deps{$_}"}/s;
}
write_file($config_path, $config);
}
sub cmp_ver {
my @a = split /(\d+)/, $a;
my @b = split /(\d+)/, $b;
my $is_num = 1;
return - 1 if $#a == 0;
return 1 if $#b == 0;
while (1) {
my $ap = shift @a;
my $bp = shift @b;
$is_num = 1 - $is_num;
if (defined $ap) {
if (defined $bp) {
if ($is_num) {
next if $ap == $bp;
return 1 if $ap > $bp;
return - 1;
} else {
next if $ap eq $bp;
return 1 if $ap gt $bp;
return - 1;
}
} else {
return 1;
}
} elsif (defined $bp) {
return - 1;
} else {
return 0;
}
}
}
sub deps_git_info {
state %info;
state $my_epoch = $epoch;
if (not %info or $my_epoch != $epoch) {
$my_epoch = $epoch;
my $deps = top_deps();
for my $dep (keys %{$deps}) {
my $dir = ".deps-update/$dep";
my @tags = `git -C "$dir" tag`;
chomp(@tags);
@tags = sort cmp_ver @tags;
my $last_tag = $tags[$#tags];
my @new = `git -C $dir log --oneline $last_tag..origin/master`;
my $new_tag = $last_tag;
$new_tag =~ s/(\d+)$/$1+1/e;
chomp(@new);
$info{$dep} = { last_tag => $last_tag, new_commits => \@new, new_tag => $new_tag };
}
}
return { %info, %info_updates };
}
sub show_commands {
my %commands = @_;
my @keys;
while (@_) {
push @keys, shift;
shift;
}
for (@keys) {
say color("red"), $_, color("reset"), ") $commands{$_}";
}
ReadMode(4);
while (1) {
my $key = ReadKey(0);
if (defined $commands{uc($key)}) {
ReadMode(0);
say "";
return uc($key);
}
}
}
sub schedule_operation {
my ($type, $dep, $tag, $reason, $op) = @_;
my $idx = first { $operations[$_]->{dep} eq $dep } 0..$#operations;
if (defined $idx) {
my $mop = $operations[$idx];
if (defined $op) {
my $oidx = first { $mop->{operations}->[$_]->[0] eq $op->[0] } 0..$#{$mop->{operations}};
if (defined $oidx) {
$mop->{reasons}->[$oidx] = $reason;
$mop->{operations}->[$oidx] = $op;
} else {
push @{$mop->{reasons}}, $reason;
push @{$mop->{operations}}, $op;
}
}
return if $type eq "update";
$mop->{type} = $type;
$info_updates{$dep}->{new_commits} = [];
return;
}
my $info = deps_git_info();
$top_deps_updates{$dep} = {commit => $tag};
$info_updates{$dep} = {last_tag => $tag, new_tag => $tag,
new_commits => $type eq "tupdate" ? [] : $info->{$dep}->{new_commits}};
my $rev_deps = rev_deps();
@operations = sort {
exists $rev_deps->{$a->{dep}}->{indirect}->{$b->{dep}} ? -1 :
exists $rev_deps->{$b->{dep}}->{indirect}->{$a->{dep}} ? 1 : $a->{dep} cmp $b->{dep}
} (@operations, {
type => $type,
dep => $dep,
version => $tag,
reasons => ($reason ? [$reason] : []),
operations => ($op ? [$op] : [])}
);
my $sub_deps = sub_deps();
for (keys %{$rev_deps->{$dep}->{direct}}) {
schedule_operation("update", $_, $info->{$_}->{new_tag}, "Updating $dep to version $tag.", [$dep, $tag]);
$sub_deps_updates{$_} = $sub_deps_updates{$_} || clone($sub_deps->{$_});
$sub_deps_updates{$_}->{$dep}->{commit} = $tag;
}
}
sub git_tag {
my ($dep, $ver, $msg) = @_;
system("git", "-C", ".deps-update/$dep", "commit", "-a", "-m", $msg);
system("git", "-C", ".deps-update/$dep", "tag", $ver);
}
sub git_push {
my ($dep) = @_;
system("git", "-C", ".deps-update/$dep", "push");
system("git", "-C", ".deps-update/$dep", "push", "--tags");
}
update_deps_repos();
MAIN:
while (1) {
my $top_deps = top_deps();
my $git_info = deps_git_info();
print color("bold blue"), "Dependences with newer tags:\n", color("reset");
my $old_deps = 0;
for my $dep (sort keys %$top_deps) {
next unless $git_info->{$dep}->{last_tag} ne $top_deps->{$dep}->{commit};
say color("red"), "$dep", color("reset"), ": $top_deps->{$dep}->{commit} -> $git_info->{$dep}->{last_tag}";
$old_deps = 1;
}
say "(none)" if not $old_deps;
say "";
print color("bold blue"), "Dependences that have commits after last tags:\n", color("reset");
my $changed_deps = 0;
for my $dep (sort keys %$top_deps) {
next unless @{$git_info->{$dep}->{new_commits}};
say color("red"), "$dep", color("reset"), " ($top_deps->{$dep}->{commit}):";
say " $_" for @{$git_info->{$dep}->{new_commits}};
$changed_deps = 1;
}
say "(none)" if not $changed_deps;
say "";
my $cmd = show_commands($old_deps ? (U => "Update dependency") : (),
$changed_deps ? (T => "Tag new release") : (),
@operations ? (A => "Apply changes") : (),
R => "Refresh repositiories",
E => "Exit");
last if $cmd eq "E";
if ($cmd eq "U") {
while (1) {
my @deps_to_update;
my @od;
my $idx = 1;
for my $dep (sort keys %$top_deps) {
next unless $git_info->{$dep}->{last_tag} ne $top_deps->{$dep}->{commit};
$od[$idx] = $dep;
push @deps_to_update, $idx++, "Update $dep to $git_info->{$dep}->{last_tag}";
}
last if $idx == 1;
my $cmd = show_commands(@deps_to_update, E => "Exit");
last if $cmd eq "E";
my $dep = $od[$cmd];
schedule_operation("update", $dep, $git_info->{$dep}->{last_tag});
$top_deps = top_deps();
$git_info = deps_git_info();
}
}
if ($cmd eq "R") {
update_deps_repos(1);
}
if ($cmd eq "T") {
while (1) {
my @deps_to_tag;
my @od;
my $idx = 1;
for my $dep (sort keys %$top_deps) {
next unless @{$git_info->{$dep}->{new_commits}};
$od[$idx] = $dep;
push @deps_to_tag, $idx++, "Tag $dep with version $git_info->{$dep}->{new_tag}";
}
last if $idx == 1;
my $cmd = show_commands(@deps_to_tag, E => "Exit");
last if $cmd eq "E";
my $dep = $od[$cmd];
my $d = $git_info->{$dep};
schedule_operation("tupdate", $dep, $d->{new_tag});
$top_deps = top_deps();
$git_info = deps_git_info();
}
}
my $changelog_updated = 0;
if ($cmd eq "A") {
APPLY: {
$top_deps = top_deps();
$git_info = deps_git_info();
my $sub_deps = sub_deps();
for my $dep (keys %$top_deps) {
for my $sdep (keys %{$sub_deps->{$dep}}) {
next if not defined $top_deps->{$sdep} or
$sub_deps->{$dep}->{$sdep}->{commit} eq $top_deps->{$sdep}->{commit};
say "$dep $sdep ", $sub_deps->{$dep}->{$sdep}->{commit}, " <=> $sdep ",
$top_deps->{$sdep}->{commit};
schedule_operation("update", $dep, $git_info->{$dep}->{new_tag},
"Updating $sdep to version $top_deps->{$sdep}->{commit}.",
[ $sdep, $top_deps->{$sdep}->{commit} ]);
}
}
%info_updates = ();
%top_deps_updates = ();
%sub_deps_updates = ();
$top_deps = top_deps();
$git_info = deps_git_info();
$sub_deps = sub_deps();
print color("bold blue"), "List of operations:\n", color("reset");
for my $op (@operations) {
print color("red"), $op->{dep}, color("reset"),
" ($top_deps->{$op->{dep}}->{commit} -> $op->{version})";
if (@{$op->{operations}}) {
say ":";
say " $_->[0] -> $_->[1]" for @{$op->{operations}};
}
else {
say "";
}
}
say "";
my %to_tag;
if (not $changelog_updated) {
for my $op (@operations) {
if ($git_info->{$op->{dep}}->{last_tag} ne $op->{version}) {
$to_tag{$op->{dep}} = $op->{version};
}
}
}
my $cmd = show_commands(A => "Apply", (%to_tag ? (U => "Update Changelogs") : ()), E => "Exit");
if ($cmd eq "U") {
for my $dep (keys %to_tag) {
edit_changelog($dep, $to_tag{$dep});
}
redo APPLY;
}
elsif ($cmd eq "A") {
my %top_changes;
for my $op (@operations) {
update_changelog($op->{dep}, $op->{version}, @{$op->{reasons}})
if @{$op->{reasons}};
update_deps_versions(".deps-update/$op->{dep}/rebar.config", map {@{$_}[0,1] } @{$op->{operations}})
if @{$op->{operations}};
if ($git_info->{$op->{dep}}->{last_tag} ne $op->{version}) {
update_app_src($op->{dep}, $op->{version});
git_tag($op->{dep}, $op->{version}, "Release $op->{version}");
}
$top_changes{$op->{dep}} = $op->{version};
}
update_deps_versions("rebar.config", %top_changes);
for my $op (@operations) {
if ($git_info->{$op->{dep}}->{last_tag} ne $op->{version}) {
git_push($op->{dep});
}
}
last MAIN;
}
}
}
}
ejabberd-18.01/sql/ 0000755 0002322 0002322 00000000000 13225664356 014442 5 ustar debalance debalance ejabberd-18.01/sql/lite.sql 0000644 0002322 0002322 00000026340 13225664356 016125 0 ustar debalance debalance --
-- ejabberd, Copyright (C) 2002-2017 ProcessOne
--
-- This program is free software; you can redistribute it and/or
-- modify it under the terms of the GNU General Public License as
-- published by the Free Software Foundation; either version 2 of the
-- License, or (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- General Public License for more details.
--
-- You should have received a copy of the GNU General Public License along
-- with this program; if not, write to the Free Software Foundation, Inc.,
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
--
CREATE TABLE users (
username text PRIMARY KEY,
password text NOT NULL,
serverkey text NOT NULL DEFAULT '',
salt text NOT NULL DEFAULT '',
iterationcount integer NOT NULL DEFAULT 0,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE last (
username text PRIMARY KEY,
seconds text NOT NULL,
state text NOT NULL
);
CREATE TABLE rosterusers (
username text NOT NULL,
jid text NOT NULL,
nick text NOT NULL,
subscription character(1) NOT NULL,
ask character(1) NOT NULL,
askmessage text NOT NULL,
server character(1) NOT NULL,
subscribe text NOT NULL,
type text,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE UNIQUE INDEX i_rosteru_user_jid ON rosterusers (username, jid);
CREATE INDEX i_rosteru_username ON rosterusers (username);
CREATE INDEX i_rosteru_jid ON rosterusers (jid);
CREATE TABLE rostergroups (
username text NOT NULL,
jid text NOT NULL,
grp text NOT NULL
);
CREATE INDEX pk_rosterg_user_jid ON rostergroups (username, jid);
CREATE TABLE sr_group (
name text NOT NULL,
opts text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE sr_user (
jid text NOT NULL,
grp text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE UNIQUE INDEX i_sr_user_jid_grp ON sr_user (jid, grp);
CREATE INDEX i_sr_user_jid ON sr_user (jid);
CREATE INDEX i_sr_user_grp ON sr_user (grp);
CREATE TABLE spool (
username text NOT NULL,
xml text NOT NULL,
seq INTEGER PRIMARY KEY AUTOINCREMENT,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX i_despool ON spool (username);
CREATE TABLE archive (
username text NOT NULL,
timestamp BIGINT UNSIGNED NOT NULL,
peer text NOT NULL,
bare_peer text NOT NULL,
xml text NOT NULL,
txt text,
id INTEGER PRIMARY KEY AUTOINCREMENT,
kind text,
nick text,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX i_username_timestamp ON archive(username, timestamp);
CREATE INDEX i_timestamp ON archive(timestamp);
CREATE INDEX i_peer ON archive(peer);
CREATE INDEX i_bare_peer ON archive(bare_peer);
CREATE TABLE archive_prefs (
username text NOT NULL PRIMARY KEY,
def text NOT NULL,
always text NOT NULL,
never text NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE vcard (
username text PRIMARY KEY,
vcard text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE vcard_search (
username text NOT NULL,
lusername text PRIMARY KEY,
fn text NOT NULL,
lfn text NOT NULL,
family text NOT NULL,
lfamily text NOT NULL,
given text NOT NULL,
lgiven text NOT NULL,
middle text NOT NULL,
lmiddle text NOT NULL,
nickname text NOT NULL,
lnickname text NOT NULL,
bday text NOT NULL,
lbday text NOT NULL,
ctry text NOT NULL,
lctry text NOT NULL,
locality text NOT NULL,
llocality text NOT NULL,
email text NOT NULL,
lemail text NOT NULL,
orgname text NOT NULL,
lorgname text NOT NULL,
orgunit text NOT NULL,
lorgunit text NOT NULL
);
CREATE INDEX i_vcard_search_lfn ON vcard_search(lfn);
CREATE INDEX i_vcard_search_lfamily ON vcard_search(lfamily);
CREATE INDEX i_vcard_search_lgiven ON vcard_search(lgiven);
CREATE INDEX i_vcard_search_lmiddle ON vcard_search(lmiddle);
CREATE INDEX i_vcard_search_lnickname ON vcard_search(lnickname);
CREATE INDEX i_vcard_search_lbday ON vcard_search(lbday);
CREATE INDEX i_vcard_search_lctry ON vcard_search(lctry);
CREATE INDEX i_vcard_search_llocality ON vcard_search(llocality);
CREATE INDEX i_vcard_search_lemail ON vcard_search(lemail);
CREATE INDEX i_vcard_search_lorgname ON vcard_search(lorgname);
CREATE INDEX i_vcard_search_lorgunit ON vcard_search(lorgunit);
CREATE TABLE privacy_default_list (
username text PRIMARY KEY,
name text NOT NULL
);
CREATE TABLE privacy_list (
username text NOT NULL,
name text NOT NULL,
id INTEGER PRIMARY KEY AUTOINCREMENT,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX i_privacy_list_username ON privacy_list (username);
CREATE UNIQUE INDEX i_privacy_list_username_name ON privacy_list (username, name);
CREATE TABLE privacy_list_data (
id bigint REFERENCES privacy_list(id) ON DELETE CASCADE,
t character(1) NOT NULL,
value text NOT NULL,
action character(1) NOT NULL,
ord NUMERIC NOT NULL,
match_all boolean NOT NULL,
match_iq boolean NOT NULL,
match_message boolean NOT NULL,
match_presence_in boolean NOT NULL,
match_presence_out boolean NOT NULL
);
CREATE TABLE private_storage (
username text NOT NULL,
namespace text NOT NULL,
data text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX i_private_storage_username ON private_storage (username);
CREATE UNIQUE INDEX i_private_storage_username_namespace ON private_storage (username, namespace);
CREATE TABLE roster_version (
username text PRIMARY KEY,
version text NOT NULL
);
CREATE TABLE pubsub_node (
host text NOT NULL,
node text NOT NULL,
parent text NOT NULL DEFAULT '',
plugin text NOT NULL,
nodeid INTEGER PRIMARY KEY AUTOINCREMENT
);
CREATE INDEX i_pubsub_node_parent ON pubsub_node (parent);
CREATE UNIQUE INDEX i_pubsub_node_tuple ON pubsub_node (host, node);
CREATE TABLE pubsub_node_option (
nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE,
name text NOT NULL,
val text NOT NULL
);
CREATE INDEX i_pubsub_node_option_nodeid ON pubsub_node_option (nodeid);
CREATE TABLE pubsub_node_owner (
nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE,
owner text NOT NULL
);
CREATE INDEX i_pubsub_node_owner_nodeid ON pubsub_node_owner (nodeid);
CREATE TABLE pubsub_state (
nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE,
jid text NOT NULL,
affiliation character(1),
subscriptions text NOT NULL DEFAULT '',
stateid INTEGER PRIMARY KEY AUTOINCREMENT
);
CREATE INDEX i_pubsub_state_jid ON pubsub_state (jid);
CREATE UNIQUE INDEX i_pubsub_state_tuple ON pubsub_state (nodeid, jid);
CREATE TABLE pubsub_item (
nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE,
itemid text NOT NULL,
publisher text NOT NULL,
creation text NOT NULL,
modification text NOT NULL,
payload text NOT NULL DEFAULT ''
);
CREATE INDEX i_pubsub_item_itemid ON pubsub_item (itemid);
CREATE UNIQUE INDEX i_pubsub_item_tuple ON pubsub_item (nodeid, itemid);
CREATE TABLE pubsub_subscription_opt (
subid text NOT NULL,
opt_name varchar(32),
opt_value text NOT NULL
);
CREATE UNIQUE INDEX i_pubsub_subscription_opt ON pubsub_subscription_opt (subid, opt_name);
CREATE TABLE muc_room (
name text NOT NULL,
host text NOT NULL,
opts text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE UNIQUE INDEX i_muc_room_name_host ON muc_room (name, host);
CREATE TABLE muc_registered (
jid text NOT NULL,
host text NOT NULL,
nick text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX i_muc_registered_nick ON muc_registered (nick);
CREATE UNIQUE INDEX i_muc_registered_jid_host ON muc_registered (jid, host);
CREATE TABLE muc_online_room (
name text NOT NULL,
host text NOT NULL,
node text NOT NULL,
pid text NOT NULL
);
CREATE UNIQUE INDEX i_muc_online_room_name_host ON muc_online_room (name, host);
CREATE TABLE muc_online_users (
username text NOT NULL,
server text NOT NULL,
resource text NOT NULL,
name text NOT NULL,
host text NOT NULL,
node text NOT NULL
);
CREATE UNIQUE INDEX i_muc_online_users ON muc_online_users (username, server, resource, name, host);
CREATE INDEX i_muc_online_users_us ON muc_online_users (username, server);
CREATE TABLE muc_room_subscribers (
room text NOT NULL,
host text NOT NULL,
jid text NOT NULL,
nick text NOT NULL,
nodes text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX i_muc_room_subscribers_host_jid ON muc_room_subscribers(host, jid);
CREATE UNIQUE INDEX i_muc_room_subscribers_host_room_jid ON muc_room_subscribers(host, room, jid);
CREATE TABLE irc_custom (
jid text NOT NULL,
host text NOT NULL,
data text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE UNIQUE INDEX i_irc_custom_jid_host ON irc_custom (jid, host);
CREATE TABLE motd (
username text PRIMARY KEY,
xml text,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE TABLE caps_features (
node text NOT NULL,
subnode text NOT NULL,
feature text,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX i_caps_features_node_subnode ON caps_features (node, subnode);
CREATE TABLE sm (
usec bigint NOT NULL,
pid text NOT NULL,
node text NOT NULL,
username text NOT NULL,
resource text NOT NULL,
priority text NOT NULL,
info text NOT NULL
);
CREATE UNIQUE INDEX i_sm_sid ON sm(usec, pid);
CREATE INDEX i_sm_node ON sm(node);
CREATE INDEX i_sm_username ON sm(username);
CREATE TABLE oauth_token (
token text NOT NULL PRIMARY KEY,
jid text NOT NULL,
scope text NOT NULL,
expire bigint NOT NULL
);
CREATE TABLE route (
domain text NOT NULL,
server_host text NOT NULL,
node text NOT NULL,
pid text NOT NULL,
local_hint text NOT NULL
);
CREATE UNIQUE INDEX i_route ON route(domain, server_host, node, pid);
CREATE INDEX i_route_domain ON route(domain);
CREATE TABLE bosh (
sid text NOT NULL,
node text NOT NULL,
pid text NOT NULL
);
CREATE UNIQUE INDEX i_bosh_sid ON bosh(sid);
CREATE TABLE carboncopy (
username text NOT NULL,
resource text NOT NULL,
namespace text NOT NULL,
node text NOT NULL
);
CREATE UNIQUE INDEX i_carboncopy_ur ON carboncopy (username, resource);
CREATE INDEX i_carboncopy_user ON carboncopy (username);
CREATE TABLE proxy65 (
sid text NOT NULL,
pid_t text NOT NULL,
pid_i text NOT NULL,
node_t text NOT NULL,
node_i text NOT NULL,
jid_i text NOT NULL
);
CREATE UNIQUE INDEX i_proxy65_sid ON proxy65 (sid);
CREATE INDEX i_proxy65_jid ON proxy65 (jid_i);
CREATE TABLE push_session (
username text NOT NULL,
timestamp bigint NOT NULL,
service text NOT NULL,
node text NOT NULL,
xml text NOT NULL
);
CREATE UNIQUE INDEX i_push_usn ON push_session (username, service, node);
CREATE UNIQUE INDEX i_push_ut ON push_session (username, timestamp);
ejabberd-18.01/sql/pg.new.sql 0000644 0002322 0002322 00000053340 13225664356 016366 0 ustar debalance debalance --
-- ejabberd, Copyright (C) 2002-2017 ProcessOne
--
-- This program is free software; you can redistribute it and/or
-- modify it under the terms of the GNU General Public License as
-- published by the Free Software Foundation; either version 2 of the
-- License, or (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- General Public License for more details.
--
-- You should have received a copy of the GNU General Public License along
-- with this program; if not, write to the Free Software Foundation, Inc.,
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
--
-- To update from the old schema, replace with the host's domain:
-- ALTER TABLE users ADD COLUMN server_host text NOT NULL DEFAULT '';
-- ALTER TABLE users DROP CONSTRAINT users_pkey;
-- ALTER TABLE users ADD PRIMARY KEY (server_host, username);
-- ALTER TABLE users ALTER COLUMN server_host DROP DEFAULT;
-- ALTER TABLE last ADD COLUMN server_host text NOT NULL DEFAULT '';
-- ALTER TABLE last DROP CONSTRAINT last_pkey;
-- ALTER TABLE last ADD PRIMARY KEY (server_host, username);
-- ALTER TABLE last ALTER COLUMN server_host DROP DEFAULT;
-- ALTER TABLE rosterusers ADD COLUMN server_host text NOT NULL DEFAULT '';
-- DROP INDEX i_rosteru_user_jid;
-- DROP INDEX i_rosteru_username;
-- DROP INDEX i_rosteru_jid;
-- CREATE UNIQUE INDEX i_rosteru_sh_user_jid ON rosterusers USING btree (server_host, username, jid);
-- CREATE INDEX i_rosteru_sh_username ON rosterusers USING btree (server_host, username);
-- CREATE INDEX i_rosteru_sh_jid ON rosterusers USING btree (server_host, jid);
-- ALTER TABLE rosterusers ALTER COLUMN server_host DROP DEFAULT;
-- ALTER TABLE rostergroups ADD COLUMN server_host text NOT NULL DEFAULT '';
-- DROP INDEX pk_rosterg_user_jid;
-- CREATE INDEX i_rosterg_sh_user_jid ON rostergroups USING btree (server_host, username, jid);
-- ALTER TABLE rostergroups ALTER COLUMN server_host DROP DEFAULT;
-- ALTER TABLE sr_group ADD COLUMN server_host text NOT NULL DEFAULT '';
-- ALTER TABLE sr_group ADD PRIMARY KEY (server_host, name);
-- ALTER TABLE sr_group ALTER COLUMN server_host DROP DEFAULT;
-- ALTER TABLE sr_user ADD COLUMN server_host text NOT NULL DEFAULT '';
-- DROP INDEX i_sr_user_jid_grp;
-- DROP INDEX i_sr_user_jid;
-- DROP INDEX i_sr_user_grp;
-- ALTER TABLE sr_user ADD PRIMARY KEY (server_host, jid, grp);
-- CREATE INDEX i_sr_user_sh_jid ON sr_user USING btree (server_host, jid);
-- CREATE INDEX i_sr_user_sh_grp ON sr_user USING btree (server_host, grp);
-- ALTER TABLE sr_user ALTER COLUMN server_host DROP DEFAULT;
-- ALTER TABLE spool ADD COLUMN server_host text NOT NULL DEFAULT '';
-- DROP INDEX i_despool;
-- CREATE INDEX i_spool_sh_username ON spool USING btree (server_host, username);
-- ALTER TABLE spool ALTER COLUMN server_host DROP DEFAULT;
-- ALTER TABLE archive ADD COLUMN server_host text NOT NULL DEFAULT '';
-- DROP INDEX i_username;
-- DROP INDEX i_username_timestamp;
-- DROP INDEX i_timestamp;
-- DROP INDEX i_peer;
-- DROP INDEX i_bare_peer;
-- CREATE INDEX i_archive_sh_username_timestamp ON archive USING btree (server_host, username, timestamp);
-- CREATE INDEX i_archive_sh_timestamp ON archive USING btree (server_host, timestamp);
-- CREATE INDEX i_archive_sh_peer ON archive USING btree (server_host, peer);
-- CREATE INDEX i_archive_sh_bare_peer ON archive USING btree (server_host, bare_peer);
-- ALTER TABLE archive ALTER COLUMN server_host DROP DEFAULT;
-- ALTER TABLE archive_prefs ADD COLUMN server_host text NOT NULL DEFAULT '';
-- ALTER TABLE archive_prefs DROP CONSTRAINT archive_prefs_pkey;
-- ALTER TABLE archive_prefs ADD PRIMARY KEY (server_host, username);
-- ALTER TABLE archive_prefs ALTER COLUMN server_host DROP DEFAULT;
-- ALTER TABLE vcard ADD COLUMN server_host text NOT NULL DEFAULT '';
-- ALTER TABLE vcard DROP CONSTRAINT vcard_pkey;
-- ALTER TABLE vcard ADD PRIMARY KEY (server_host, username);
-- ALTER TABLE vcard ALTER COLUMN server_host DROP DEFAULT;
-- ALTER TABLE vcard_search ADD COLUMN server_host text NOT NULL DEFAULT '';
-- ALTER TABLE vcard_search DROP CONSTRAINT vcard_search_pkey;
-- DROP INDEX i_vcard_search_lfn;
-- DROP INDEX i_vcard_search_lfamily;
-- DROP INDEX i_vcard_search_lgiven;
-- DROP INDEX i_vcard_search_lmiddle;
-- DROP INDEX i_vcard_search_lnickname;
-- DROP INDEX i_vcard_search_lbday;
-- DROP INDEX i_vcard_search_lctry;
-- DROP INDEX i_vcard_search_llocality;
-- DROP INDEX i_vcard_search_lemail;
-- DROP INDEX i_vcard_search_lorgname;
-- DROP INDEX i_vcard_search_lorgunit;
-- ALTER TABLE vcard_search ADD PRIMARY KEY (server_host, username);
-- CREATE INDEX i_vcard_search_sh_lfn ON vcard_search(server_host, lfn);
-- CREATE INDEX i_vcard_search_sh_lfamily ON vcard_search(server_host, lfamily);
-- CREATE INDEX i_vcard_search_sh_lgiven ON vcard_search(server_host, lgiven);
-- CREATE INDEX i_vcard_search_sh_lmiddle ON vcard_search(server_host, lmiddle);
-- CREATE INDEX i_vcard_search_sh_lnickname ON vcard_search(server_host, lnickname);
-- CREATE INDEX i_vcard_search_sh_lbday ON vcard_search(server_host, lbday);
-- CREATE INDEX i_vcard_search_sh_lctry ON vcard_search(server_host, lctry);
-- CREATE INDEX i_vcard_search_sh_llocality ON vcard_search(server_host, llocality);
-- CREATE INDEX i_vcard_search_sh_lemail ON vcard_search(server_host, lemail);
-- CREATE INDEX i_vcard_search_sh_lorgname ON vcard_search(server_host, lorgname);
-- CREATE INDEX i_vcard_search_sh_lorgunit ON vcard_search(server_host, lorgunit);
-- ALTER TABLE vcard_search ALTER COLUMN server_host DROP DEFAULT;
-- ALTER TABLE privacy_default_list ADD COLUMN server_host text NOT NULL DEFAULT '';
-- ALTER TABLE privacy_default_list DROP CONSTRAINT privacy_default_list_pkey;
-- ALTER TABLE privacy_default_list ADD PRIMARY KEY (server_host, username);
-- ALTER TABLE privacy_default_list ALTER COLUMN server_host DROP DEFAULT;
-- ALTER TABLE privacy_list ADD COLUMN server_host text NOT NULL DEFAULT '';
-- DROP INDEX i_privacy_list_username;
-- DROP INDEX i_privacy_list_username_name;
-- CREATE INDEX i_privacy_list_sh_username ON privacy_list USING btree (server_host, username);
-- CREATE UNIQUE INDEX i_privacy_list_sh_username_name ON privacy_list USING btree (server_host, username, name);
-- ALTER TABLE privacy_list ALTER COLUMN server_host DROP DEFAULT;
-- ALTER TABLE private_storage ADD COLUMN server_host text NOT NULL DEFAULT '';
-- DROP INDEX i_private_storage_username;
-- DROP INDEX i_private_storage_username_namespace;
-- ALTER TABLE private_storage ADD PRIMARY KEY (server_host, username, namespace);
-- CREATE INDEX i_private_storage_sh_username ON private_storage USING btree (server_host, username);
-- ALTER TABLE private_storage ALTER COLUMN server_host DROP DEFAULT;
-- ALTER TABLE roster_version ADD COLUMN server_host text NOT NULL DEFAULT '';
-- ALTER TABLE roster_version DROP CONSTRAINT roster_version_pkey;
-- ALTER TABLE roster_version ADD PRIMARY KEY (server_host, username);
-- ALTER TABLE roster_version ALTER COLUMN server_host DROP DEFAULT;
-- ALTER TABLE muc_room ADD COLUMN server_host text NOT NULL DEFAULT '';
-- ALTER TABLE muc_room ALTER COLUMN server_host DROP DEFAULT;
-- ALTER TABLE muc_registered ADD COLUMN server_host text NOT NULL DEFAULT '';
-- ALTER TABLE muc_registered ALTER COLUMN server_host DROP DEFAULT;
-- ALTER TABLE muc_online_room ADD COLUMN server_host text NOT NULL DEFAULT '';
-- ALTER TABLE muc_online_room ALTER COLUMN server_host DROP DEFAULT;
-- ALTER TABLE muc_online_users ADD COLUMN server_host text NOT NULL DEFAULT '';
-- ALTER TABLE muc_online_users ALTER COLUMN server_host DROP DEFAULT;
-- ALTER TABLE irc_custom ADD COLUMN server_host text NOT NULL DEFAULT '';
-- ALTER TABLE irc_custom ALTER COLUMN server_host DROP DEFAULT;
-- ALTER TABLE motd ADD COLUMN server_host text NOT NULL DEFAULT '';
-- ALTER TABLE motd DROP CONSTRAINT motd_pkey;
-- ALTER TABLE motd ADD PRIMARY KEY (server_host, username);
-- ALTER TABLE motd ALTER COLUMN server_host DROP DEFAULT;
-- ALTER TABLE sm ADD COLUMN server_host text NOT NULL DEFAULT '';
-- DROP INDEX i_sm_sid;
-- DROP INDEX i_sm_username;
-- ALTER TABLE sm ADD PRIMARY KEY (usec, pid);
-- CREATE INDEX i_sm_sh_username ON sm USING btree (server_host, username);
-- ALTER TABLE sm ALTER COLUMN server_host DROP DEFAULT;
-- ALTER TABLE carboncopy ADD COLUMN server_host text NOT NULL DEFAULT '';
-- DROP INDEX i_carboncopy_ur;
-- DROP INDEX i_carboncopy_user;
-- ALTER TABLE carboncopy ADD PRIMARY KEY (server_host, username, resource);
-- CREATE INDEX i_carboncopy_sh_user ON carboncopy USING btree (server_host, username);
-- ALTER TABLE carboncopy ALTER COLUMN server_host DROP DEFAULT;
CREATE TABLE users (
username text NOT NULL,
server_host text NOT NULL,
"password" text NOT NULL,
serverkey text NOT NULL DEFAULT '',
salt text NOT NULL DEFAULT '',
iterationcount integer NOT NULL DEFAULT 0,
created_at TIMESTAMP NOT NULL DEFAULT now(),
PRIMARY KEY (server_host, username)
);
-- Add support for SCRAM auth to a database created before ejabberd 16.03:
-- ALTER TABLE users ADD COLUMN serverkey text NOT NULL DEFAULT '';
-- ALTER TABLE users ADD COLUMN salt text NOT NULL DEFAULT '';
-- ALTER TABLE users ADD COLUMN iterationcount integer NOT NULL DEFAULT 0;
CREATE TABLE last (
username text NOT NULL,
server_host text NOT NULL,
seconds text NOT NULL,
state text NOT NULL,
PRIMARY KEY (server_host, username)
);
CREATE TABLE rosterusers (
username text NOT NULL,
server_host text NOT NULL,
jid text NOT NULL,
nick text NOT NULL,
subscription character(1) NOT NULL,
ask character(1) NOT NULL,
askmessage text NOT NULL,
server character(1) NOT NULL,
subscribe text NOT NULL,
"type" text,
created_at TIMESTAMP NOT NULL DEFAULT now()
);
CREATE UNIQUE INDEX i_rosteru_sh_user_jid ON rosterusers USING btree (server_host, username, jid);
CREATE INDEX i_rosteru_sh_username ON rosterusers USING btree (server_host, username);
CREATE INDEX i_rosteru_sh_jid ON rosterusers USING btree (server_host, jid);
CREATE TABLE rostergroups (
username text NOT NULL,
server_host text NOT NULL,
jid text NOT NULL,
grp text NOT NULL
);
CREATE INDEX i_rosterg_sh_user_jid ON rostergroups USING btree (server_host, username, jid);
CREATE TABLE sr_group (
name text NOT NULL,
server_host text NOT NULL,
opts text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT now(),
PRIMARY KEY (server_host, name)
);
CREATE TABLE sr_user (
jid text NOT NULL,
server_host text NOT NULL,
grp text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT now(),
PRIMARY KEY (server_host, jid, grp)
);
CREATE INDEX i_sr_user_sh_jid ON sr_user USING btree (server_host, jid);
CREATE INDEX i_sr_user_sh_grp ON sr_user USING btree (server_host, grp);
CREATE TABLE spool (
username text NOT NULL,
server_host text NOT NULL,
xml text NOT NULL,
seq SERIAL,
created_at TIMESTAMP NOT NULL DEFAULT now()
);
CREATE INDEX i_spool_sh_username ON spool USING btree (server_host, username);
CREATE TABLE archive (
username text NOT NULL,
server_host text NOT NULL,
timestamp BIGINT NOT NULL,
peer text NOT NULL,
bare_peer text NOT NULL,
xml text NOT NULL,
txt text,
id SERIAL,
kind text,
nick text,
created_at TIMESTAMP NOT NULL DEFAULT now()
);
CREATE INDEX i_archive_sh_username_timestamp ON archive USING btree (server_host, username, timestamp);
CREATE INDEX i_archive_sh_timestamp ON archive USING btree (server_host, timestamp);
CREATE INDEX i_archive_sh_peer ON archive USING btree (server_host, peer);
CREATE INDEX i_archive_sh_bare_peer ON archive USING btree (server_host, bare_peer);
CREATE TABLE archive_prefs (
username text NOT NULL,
server_host text NOT NULL,
def text NOT NULL,
always text NOT NULL,
never text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT now(),
PRIMARY KEY (server_host, username)
);
CREATE TABLE vcard (
username text NOT NULL,
server_host text NOT NULL,
vcard text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT now(),
PRIMARY KEY (server_host, username)
);
CREATE TABLE vcard_search (
username text NOT NULL,
lusername text NOT NULL,
server_host text NOT NULL,
fn text NOT NULL,
lfn text NOT NULL,
family text NOT NULL,
lfamily text NOT NULL,
given text NOT NULL,
lgiven text NOT NULL,
middle text NOT NULL,
lmiddle text NOT NULL,
nickname text NOT NULL,
lnickname text NOT NULL,
bday text NOT NULL,
lbday text NOT NULL,
ctry text NOT NULL,
lctry text NOT NULL,
locality text NOT NULL,
llocality text NOT NULL,
email text NOT NULL,
lemail text NOT NULL,
orgname text NOT NULL,
lorgname text NOT NULL,
orgunit text NOT NULL,
lorgunit text NOT NULL,
PRIMARY KEY (server_host, username)
);
CREATE INDEX i_vcard_search_sh_lfn ON vcard_search(server_host, lfn);
CREATE INDEX i_vcard_search_sh_lfamily ON vcard_search(server_host, lfamily);
CREATE INDEX i_vcard_search_sh_lgiven ON vcard_search(server_host, lgiven);
CREATE INDEX i_vcard_search_sh_lmiddle ON vcard_search(server_host, lmiddle);
CREATE INDEX i_vcard_search_sh_lnickname ON vcard_search(server_host, lnickname);
CREATE INDEX i_vcard_search_sh_lbday ON vcard_search(server_host, lbday);
CREATE INDEX i_vcard_search_sh_lctry ON vcard_search(server_host, lctry);
CREATE INDEX i_vcard_search_sh_llocality ON vcard_search(server_host, llocality);
CREATE INDEX i_vcard_search_sh_lemail ON vcard_search(server_host, lemail);
CREATE INDEX i_vcard_search_sh_lorgname ON vcard_search(server_host, lorgname);
CREATE INDEX i_vcard_search_sh_lorgunit ON vcard_search(server_host, lorgunit);
CREATE TABLE privacy_default_list (
username text NOT NULL,
server_host text NOT NULL,
name text NOT NULL,
PRIMARY KEY (server_host, username)
);
CREATE TABLE privacy_list (
username text NOT NULL,
server_host text NOT NULL,
name text NOT NULL,
id SERIAL UNIQUE,
created_at TIMESTAMP NOT NULL DEFAULT now()
);
CREATE INDEX i_privacy_list_sh_username ON privacy_list USING btree (server_host, username);
CREATE UNIQUE INDEX i_privacy_list_sh_username_name ON privacy_list USING btree (server_host, username, name);
CREATE TABLE privacy_list_data (
id bigint REFERENCES privacy_list(id) ON DELETE CASCADE,
t character(1) NOT NULL,
value text NOT NULL,
action character(1) NOT NULL,
ord NUMERIC NOT NULL,
match_all boolean NOT NULL,
match_iq boolean NOT NULL,
match_message boolean NOT NULL,
match_presence_in boolean NOT NULL,
match_presence_out boolean NOT NULL
);
CREATE INDEX i_privacy_list_data_id ON privacy_list_data USING btree (id);
CREATE TABLE private_storage (
username text NOT NULL,
server_host text NOT NULL,
namespace text NOT NULL,
data text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT now(),
PRIMARY KEY (server_host, username, namespace)
);
CREATE INDEX i_private_storage_sh_username ON private_storage USING btree (server_host, username);
CREATE TABLE roster_version (
username text NOT NULL,
server_host text NOT NULL,
version text NOT NULL,
PRIMARY KEY (server_host, username)
);
-- To update from 0.9.8:
-- CREATE SEQUENCE spool_seq_seq;
-- ALTER TABLE spool ADD COLUMN seq integer;
-- ALTER TABLE spool ALTER COLUMN seq SET DEFAULT nextval('spool_seq_seq');
-- UPDATE spool SET seq = DEFAULT;
-- ALTER TABLE spool ALTER COLUMN seq SET NOT NULL;
-- To update from 1.x:
-- ALTER TABLE rosterusers ADD COLUMN askmessage text;
-- UPDATE rosterusers SET askmessage = '';
-- ALTER TABLE rosterusers ALTER COLUMN askmessage SET NOT NULL;
CREATE TABLE pubsub_node (
host text NOT NULL,
node text NOT NULL,
parent text NOT NULL DEFAULT '',
plugin text NOT NULL,
nodeid SERIAL UNIQUE
);
CREATE INDEX i_pubsub_node_parent ON pubsub_node USING btree (parent);
CREATE UNIQUE INDEX i_pubsub_node_tuple ON pubsub_node USING btree (host, node);
CREATE TABLE pubsub_node_option (
nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE,
name text NOT NULL,
val text NOT NULL
);
CREATE INDEX i_pubsub_node_option_nodeid ON pubsub_node_option USING btree (nodeid);
CREATE TABLE pubsub_node_owner (
nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE,
owner text NOT NULL
);
CREATE INDEX i_pubsub_node_owner_nodeid ON pubsub_node_owner USING btree (nodeid);
CREATE TABLE pubsub_state (
nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE,
jid text NOT NULL,
affiliation character(1),
subscriptions text NOT NULL DEFAULT '',
stateid SERIAL UNIQUE
);
CREATE INDEX i_pubsub_state_jid ON pubsub_state USING btree (jid);
CREATE UNIQUE INDEX i_pubsub_state_tuple ON pubsub_state USING btree (nodeid, jid);
CREATE TABLE pubsub_item (
nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE,
itemid text NOT NULL,
publisher text NOT NULL,
creation text NOT NULL,
modification text NOT NULL,
payload text NOT NULL DEFAULT ''
);
CREATE INDEX i_pubsub_item_itemid ON pubsub_item USING btree (itemid);
CREATE UNIQUE INDEX i_pubsub_item_tuple ON pubsub_item USING btree (nodeid, itemid);
CREATE TABLE pubsub_subscription_opt (
subid text NOT NULL,
opt_name varchar(32),
opt_value text NOT NULL
);
CREATE UNIQUE INDEX i_pubsub_subscription_opt ON pubsub_subscription_opt USING btree (subid, opt_name);
CREATE TABLE muc_room (
name text NOT NULL,
host text NOT NULL,
server_host text NOT NULL,
opts text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT now()
);
CREATE UNIQUE INDEX i_muc_room_name_host ON muc_room USING btree (name, host);
CREATE TABLE muc_registered (
jid text NOT NULL,
host text NOT NULL,
server_host text NOT NULL,
nick text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT now()
);
CREATE INDEX i_muc_registered_nick ON muc_registered USING btree (nick);
CREATE UNIQUE INDEX i_muc_registered_jid_host ON muc_registered USING btree (jid, host);
CREATE TABLE muc_online_room (
name text NOT NULL,
host text NOT NULL,
server_host text NOT NULL,
node text NOT NULL,
pid text NOT NULL
);
CREATE UNIQUE INDEX i_muc_online_room_name_host ON muc_online_room USING btree (name, host);
CREATE TABLE muc_online_users (
username text NOT NULL,
server text NOT NULL,
resource text NOT NULL,
name text NOT NULL,
host text NOT NULL,
server_host text NOT NULL,
node text NOT NULL
);
CREATE UNIQUE INDEX i_muc_online_users ON muc_online_users USING btree (username, server, resource, name, host);
CREATE INDEX i_muc_online_users_us ON muc_online_users USING btree (username, server);
CREATE TABLE muc_room_subscribers (
room text NOT NULL,
host text NOT NULL,
jid text NOT NULL,
nick text NOT NULL,
nodes text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT now()
);
CREATE INDEX i_muc_room_subscribers_host_jid ON muc_room_subscribers USING btree (host, jid);
CREATE UNIQUE INDEX i_muc_room_subscribers_host_room_jid ON muc_room_subscribers USING btree (host, room, jid);
CREATE TABLE irc_custom (
jid text NOT NULL,
host text NOT NULL,
server_host text NOT NULL,
data text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT now()
);
CREATE UNIQUE INDEX i_irc_custom_jid_host ON irc_custom USING btree (jid, host);
CREATE TABLE motd (
username text NOT NULL,
server_host text NOT NULL,
xml text,
created_at TIMESTAMP NOT NULL DEFAULT now(),
PRIMARY KEY (server_host, username)
);
CREATE TABLE caps_features (
node text NOT NULL,
subnode text NOT NULL,
feature text,
created_at TIMESTAMP NOT NULL DEFAULT now()
);
CREATE INDEX i_caps_features_node_subnode ON caps_features USING btree (node, subnode);
CREATE TABLE sm (
usec bigint NOT NULL,
pid text NOT NULL,
node text NOT NULL,
username text NOT NULL,
server_host text NOT NULL,
resource text NOT NULL,
priority text NOT NULL,
info text NOT NULL,
PRIMARY KEY (usec, pid)
);
CREATE INDEX i_sm_node ON sm USING btree (node);
CREATE INDEX i_sm_sh_username ON sm USING btree (server_host, username);
CREATE TABLE oauth_token (
token text NOT NULL,
jid text NOT NULL,
scope text NOT NULL,
expire bigint NOT NULL
);
CREATE UNIQUE INDEX i_oauth_token_token ON oauth_token USING btree (token);
CREATE TABLE route (
domain text NOT NULL,
server_host text NOT NULL,
node text NOT NULL,
pid text NOT NULL,
local_hint text NOT NULL
);
CREATE UNIQUE INDEX i_route ON route USING btree (domain, server_host, node, pid);
CREATE INDEX i_route_domain ON route USING btree (domain);
CREATE TABLE bosh (
sid text NOT NULL,
node text NOT NULL,
pid text NOT NULL
);
CREATE UNIQUE INDEX i_bosh_sid ON bosh USING btree (sid);
CREATE TABLE carboncopy (
username text NOT NULL,
server_host text NOT NULL,
resource text NOT NULL,
namespace text NOT NULL,
node text NOT NULL,
PRIMARY KEY (server_host, username, resource)
);
CREATE INDEX i_carboncopy_sh_user ON carboncopy USING btree (server_host, username);
CREATE TABLE proxy65 (
sid text NOT NULL,
pid_t text NOT NULL,
pid_i text NOT NULL,
node_t text NOT NULL,
node_i text NOT NULL,
jid_i text NOT NULL
);
CREATE UNIQUE INDEX i_proxy65_sid ON proxy65 USING btree (sid);
CREATE INDEX i_proxy65_jid ON proxy65 USING btree (jid_i);
CREATE TABLE push_session (
username text NOT NULL,
server_host text NOT NULL,
timestamp bigint NOT NULL,
service text NOT NULL,
node text NOT NULL,
xml text NOT NULL,
PRIMARY KEY (server_host, username, timestamp)
);
CREATE UNIQUE INDEX i_push_session_susn ON push_session USING btree (server_host, username, service, node);
ejabberd-18.01/sql/mysql.sql 0000644 0002322 0002322 00000036127 13225664356 016341 0 ustar debalance debalance --
-- ejabberd, Copyright (C) 2002-2017 ProcessOne
--
-- This program is free software; you can redistribute it and/or
-- modify it under the terms of the GNU General Public License as
-- published by the Free Software Foundation; either version 2 of the
-- License, or (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- General Public License for more details.
--
-- You should have received a copy of the GNU General Public License along
-- with this program; if not, write to the Free Software Foundation, Inc.,
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
--
CREATE TABLE users (
username varchar(191) PRIMARY KEY,
password text NOT NULL,
serverkey varchar(64) NOT NULL DEFAULT '',
salt varchar(64) NOT NULL DEFAULT '',
iterationcount integer NOT NULL DEFAULT 0,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Add support for SCRAM auth to a database created before ejabberd 16.03:
-- ALTER TABLE users ADD COLUMN serverkey varchar(64) NOT NULL DEFAULT '';
-- ALTER TABLE users ADD COLUMN salt varchar(64) NOT NULL DEFAULT '';
-- ALTER TABLE users ADD COLUMN iterationcount integer NOT NULL DEFAULT 0;
CREATE TABLE last (
username varchar(191) PRIMARY KEY,
seconds text NOT NULL,
state text NOT NULl
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE rosterusers (
username varchar(191) NOT NULL,
jid varchar(191) NOT NULL,
nick text NOT NULL,
subscription character(1) NOT NULL,
ask character(1) NOT NULL,
askmessage text NOT NULL,
server character(1) NOT NULL,
subscribe text NOT NULL,
type text,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE UNIQUE INDEX i_rosteru_user_jid ON rosterusers(username(75), jid(75));
CREATE INDEX i_rosteru_username ON rosterusers(username);
CREATE INDEX i_rosteru_jid ON rosterusers(jid);
CREATE TABLE rostergroups (
username varchar(191) NOT NULL,
jid varchar(191) NOT NULL,
grp text NOT NULL
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE INDEX pk_rosterg_user_jid ON rostergroups(username(75), jid(75));
CREATE TABLE sr_group (
name varchar(191) NOT NULL,
opts text NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE sr_user (
jid varchar(191) NOT NULL,
grp varchar(191) NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE UNIQUE INDEX i_sr_user_jid_group ON sr_user(jid(75), grp(75));
CREATE INDEX i_sr_user_jid ON sr_user(jid);
CREATE INDEX i_sr_user_grp ON sr_user(grp);
CREATE TABLE spool (
username varchar(191) NOT NULL,
xml BLOB NOT NULL,
seq BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE INDEX i_despool USING BTREE ON spool(username);
CREATE INDEX i_spool_created_at USING BTREE ON spool(created_at);
CREATE TABLE archive (
username varchar(191) NOT NULL,
timestamp BIGINT UNSIGNED NOT NULL,
peer varchar(191) NOT NULL,
bare_peer varchar(191) NOT NULL,
xml text NOT NULL,
txt text,
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE,
kind varchar(10),
nick varchar(191),
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE FULLTEXT INDEX i_text ON archive(txt);
CREATE INDEX i_username_timestamp USING BTREE ON archive(username,timestamp);
CREATE INDEX i_timestamp USING BTREE ON archive(timestamp);
CREATE INDEX i_peer USING BTREE ON archive(peer);
CREATE INDEX i_bare_peer USING BTREE ON archive(bare_peer);
CREATE TABLE archive_prefs (
username varchar(191) NOT NULL PRIMARY KEY,
def text NOT NULL,
always text NOT NULL,
never text NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE vcard (
username varchar(191) PRIMARY KEY,
vcard mediumtext NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE vcard_search (
username varchar(191) NOT NULL,
lusername varchar(191) PRIMARY KEY,
fn text NOT NULL,
lfn varchar(191) NOT NULL,
family text NOT NULL,
lfamily varchar(191) NOT NULL,
given text NOT NULL,
lgiven varchar(191) NOT NULL,
middle text NOT NULL,
lmiddle varchar(191) NOT NULL,
nickname text NOT NULL,
lnickname varchar(191) NOT NULL,
bday text NOT NULL,
lbday varchar(191) NOT NULL,
ctry text NOT NULL,
lctry varchar(191) NOT NULL,
locality text NOT NULL,
llocality varchar(191) NOT NULL,
email text NOT NULL,
lemail varchar(191) NOT NULL,
orgname text NOT NULL,
lorgname varchar(191) NOT NULL,
orgunit text NOT NULL,
lorgunit varchar(191) NOT NULL
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE INDEX i_vcard_search_lfn ON vcard_search(lfn);
CREATE INDEX i_vcard_search_lfamily ON vcard_search(lfamily);
CREATE INDEX i_vcard_search_lgiven ON vcard_search(lgiven);
CREATE INDEX i_vcard_search_lmiddle ON vcard_search(lmiddle);
CREATE INDEX i_vcard_search_lnickname ON vcard_search(lnickname);
CREATE INDEX i_vcard_search_lbday ON vcard_search(lbday);
CREATE INDEX i_vcard_search_lctry ON vcard_search(lctry);
CREATE INDEX i_vcard_search_llocality ON vcard_search(llocality);
CREATE INDEX i_vcard_search_lemail ON vcard_search(lemail);
CREATE INDEX i_vcard_search_lorgname ON vcard_search(lorgname);
CREATE INDEX i_vcard_search_lorgunit ON vcard_search(lorgunit);
CREATE TABLE privacy_default_list (
username varchar(191) PRIMARY KEY,
name varchar(191) NOT NULL
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE privacy_list (
username varchar(191) NOT NULL,
name varchar(191) NOT NULL,
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE INDEX i_privacy_list_username USING BTREE ON privacy_list(username);
CREATE UNIQUE INDEX i_privacy_list_username_name USING BTREE ON privacy_list (username(75), name(75));
CREATE TABLE privacy_list_data (
id bigint,
t character(1) NOT NULL,
value text NOT NULL,
action character(1) NOT NULL,
ord NUMERIC NOT NULL,
match_all boolean NOT NULL,
match_iq boolean NOT NULL,
match_message boolean NOT NULL,
match_presence_in boolean NOT NULL,
match_presence_out boolean NOT NULL
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE INDEX i_privacy_list_data_id ON privacy_list_data(id);
CREATE TABLE private_storage (
username varchar(191) NOT NULL,
namespace varchar(191) NOT NULL,
data text NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE INDEX i_private_storage_username USING BTREE ON private_storage(username);
CREATE UNIQUE INDEX i_private_storage_username_namespace USING BTREE ON private_storage(username(75), namespace(75));
-- Not tested in mysql
CREATE TABLE roster_version (
username varchar(191) PRIMARY KEY,
version text NOT NULL
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- To update from 1.x:
-- ALTER TABLE rosterusers ADD COLUMN askmessage text AFTER ask;
-- UPDATE rosterusers SET askmessage = '';
-- ALTER TABLE rosterusers ALTER COLUMN askmessage SET NOT NULL;
CREATE TABLE pubsub_node (
host text NOT NULL,
node text NOT NULL,
parent VARCHAR(191) NOT NULL DEFAULT '',
plugin text NOT NULL,
nodeid bigint auto_increment primary key
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE INDEX i_pubsub_node_parent ON pubsub_node(parent(120));
CREATE UNIQUE INDEX i_pubsub_node_tuple ON pubsub_node(host(20), node(120));
CREATE TABLE pubsub_node_option (
nodeid bigint,
name text NOT NULL,
val text NOT NULL
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE INDEX i_pubsub_node_option_nodeid ON pubsub_node_option(nodeid);
ALTER TABLE `pubsub_node_option` ADD FOREIGN KEY (`nodeid`) REFERENCES `pubsub_node` (`nodeid`) ON DELETE CASCADE;
CREATE TABLE pubsub_node_owner (
nodeid bigint,
owner text NOT NULL
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE INDEX i_pubsub_node_owner_nodeid ON pubsub_node_owner(nodeid);
ALTER TABLE `pubsub_node_owner` ADD FOREIGN KEY (`nodeid`) REFERENCES `pubsub_node` (`nodeid`) ON DELETE CASCADE;
CREATE TABLE pubsub_state (
nodeid bigint,
jid text NOT NULL,
affiliation character(1),
subscriptions VARCHAR(191) NOT NULL DEFAULT '',
stateid bigint auto_increment primary key
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE INDEX i_pubsub_state_jid ON pubsub_state(jid(60));
CREATE UNIQUE INDEX i_pubsub_state_tuple ON pubsub_state(nodeid, jid(60));
ALTER TABLE `pubsub_state` ADD FOREIGN KEY (`nodeid`) REFERENCES `pubsub_node` (`nodeid`) ON DELETE CASCADE;
CREATE TABLE pubsub_item (
nodeid bigint,
itemid text NOT NULL,
publisher text NOT NULL,
creation text NOT NULL,
modification text NOT NULL,
payload text NOT NULL
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE INDEX i_pubsub_item_itemid ON pubsub_item(itemid(36));
CREATE UNIQUE INDEX i_pubsub_item_tuple ON pubsub_item(nodeid, itemid(36));
ALTER TABLE `pubsub_item` ADD FOREIGN KEY (`nodeid`) REFERENCES `pubsub_node` (`nodeid`) ON DELETE CASCADE;
CREATE TABLE pubsub_subscription_opt (
subid text NOT NULL,
opt_name varchar(32),
opt_value text NOT NULL
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE UNIQUE INDEX i_pubsub_subscription_opt ON pubsub_subscription_opt(subid(32), opt_name(32));
CREATE TABLE muc_room (
name text NOT NULL,
host text NOT NULL,
opts mediumtext NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE UNIQUE INDEX i_muc_room_name_host USING BTREE ON muc_room(name(75), host(75));
CREATE TABLE muc_registered (
jid text NOT NULL,
host text NOT NULL,
nick text NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE INDEX i_muc_registered_nick USING BTREE ON muc_registered(nick(75));
CREATE UNIQUE INDEX i_muc_registered_jid_host USING BTREE ON muc_registered(jid(75), host(75));
CREATE TABLE muc_online_room (
name text NOT NULL,
host text NOT NULL,
node text NOT NULL,
pid text NOT NULL
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE UNIQUE INDEX i_muc_online_room_name_host USING BTREE ON muc_online_room(name(75), host(75));
CREATE TABLE muc_online_users (
username text NOT NULL,
server text NOT NULL,
resource text NOT NULL,
name text NOT NULL,
host text NOT NULL,
node text NOT NULL
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE UNIQUE INDEX i_muc_online_users USING BTREE ON muc_online_users(username(75), server(75), resource(75), name(75), host(75));
CREATE INDEX i_muc_online_users_us USING BTREE ON muc_online_users(username(75), server(75));
CREATE TABLE muc_room_subscribers (
room varchar(191) NOT NULL,
host varchar(191) NOT NULL,
jid varchar(191) NOT NULL,
nick text NOT NULL,
nodes text NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
UNIQUE KEY i_muc_room_subscribers_host_room_jid (host, room, jid)
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE INDEX i_muc_room_subscribers_host_jid USING BTREE ON muc_room_subscribers(host, jid);
CREATE TABLE irc_custom (
jid text NOT NULL,
host text NOT NULL,
data text NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE UNIQUE INDEX i_irc_custom_jid_host USING BTREE ON irc_custom(jid(75), host(75));
CREATE TABLE motd (
username varchar(191) PRIMARY KEY,
xml text,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE caps_features (
node varchar(191) NOT NULL,
subnode varchar(191) NOT NULL,
feature text,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE INDEX i_caps_features_node_subnode ON caps_features(node(75), subnode(75));
CREATE TABLE sm (
usec bigint NOT NULL,
pid text NOT NULL,
node text NOT NULL,
username varchar(191) NOT NULL,
resource varchar(191) NOT NULL,
priority text NOT NULL,
info text NOT NULL
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE UNIQUE INDEX i_sid ON sm(usec, pid(75));
CREATE INDEX i_node ON sm(node(75));
CREATE INDEX i_username ON sm(username);
CREATE TABLE oauth_token (
token varchar(191) NOT NULL PRIMARY KEY,
jid text NOT NULL,
scope text NOT NULL,
expire bigint NOT NULL
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE route (
domain text NOT NULL,
server_host text NOT NULL,
node text NOT NULL,
pid text NOT NULL,
local_hint text NOT NULL
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE UNIQUE INDEX i_route ON route(domain(75), server_host(75), node(75), pid(75));
CREATE INDEX i_route_domain ON route(domain(75));
CREATE TABLE bosh (
sid text NOT NULL,
node text NOT NULL,
pid text NOT NULL
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE UNIQUE INDEX i_bosh_sid ON bosh(sid(75));
CREATE TABLE carboncopy (
username text NOT NULL,
resource text NOT NULL,
namespace text NOT NULL,
node text NOT NULL
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE UNIQUE INDEX i_carboncopy_ur ON carboncopy (username(75), resource(75));
CREATE INDEX i_carboncopy_user ON carboncopy (username(75));
CREATE TABLE proxy65 (
sid text NOT NULL,
pid_t text NOT NULL,
pid_i text NOT NULL,
node_t text NOT NULL,
node_i text NOT NULL,
jid_i text NOT NULL
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE UNIQUE INDEX i_proxy65_sid ON proxy65 (sid(191));
CREATE INDEX i_proxy65_jid ON proxy65 (jid_i(191));
CREATE TABLE push_session (
username text NOT NULL,
timestamp bigint NOT NULL,
service text NOT NULL,
node text NOT NULL,
xml text NOT NULL
);
CREATE UNIQUE INDEX i_push_usn ON push_session (username(191), service(191), node(191));
CREATE UNIQUE INDEX i_push_ut ON push_session (username(191), timestamp);
ejabberd-18.01/sql/mysql.new.sql 0000644 0002322 0002322 00000041257 13225664356 017131 0 ustar debalance debalance --
-- ejabberd, Copyright (C) 2002-2017 ProcessOne
--
-- This program is free software; you can redistribute it and/or
-- modify it under the terms of the GNU General Public License as
-- published by the Free Software Foundation; either version 2 of the
-- License, or (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- General Public License for more details.
--
-- You should have received a copy of the GNU General Public License along
-- with this program; if not, write to the Free Software Foundation, Inc.,
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
--
CREATE TABLE users (
username varchar(191) NOT NULL,
server_host text NOT NULL,
password text NOT NULL,
serverkey varchar(64) NOT NULL DEFAULT '',
salt varchar(64) NOT NULL DEFAULT '',
iterationcount integer NOT NULL DEFAULT 0,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (server_host(191), username)
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- Add support for SCRAM auth to a database created before ejabberd 16.03:
-- ALTER TABLE users ADD COLUMN serverkey varchar(64) NOT NULL DEFAULT '';
-- ALTER TABLE users ADD COLUMN salt varchar(64) NOT NULL DEFAULT '';
-- ALTER TABLE users ADD COLUMN iterationcount integer NOT NULL DEFAULT 0;
CREATE TABLE last (
username varchar(191) NOT NULL,
server_host text NOT NULL,
seconds text NOT NULL,
state text NOT NULL,
PRIMARY KEY (server_host(191), username)
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE rosterusers (
username varchar(191) NOT NULL,
server_host text NOT NULL,
jid varchar(191) NOT NULL,
nick text NOT NULL,
subscription character(1) NOT NULL,
ask character(1) NOT NULL,
askmessage text NOT NULL,
server character(1) NOT NULL,
subscribe text NOT NULL,
type text,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE UNIQUE INDEX i_rosteru_sh_user_jid ON rosterusers(server_host(191), username(75), jid(75));
CREATE INDEX i_rosteru_sh_username ON rosterusers(server_host(191), username);
CREATE INDEX i_rosteru_sh_jid ON rosterusers(server_host(191), jid);
CREATE TABLE rostergroups (
username varchar(191) NOT NULL,
server_host text NOT NULL,
jid varchar(191) NOT NULL,
grp text NOT NULL
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE INDEX i_rosterg_sh_user_jid ON rostergroups(server_host(191), username(75), jid(75));
CREATE TABLE sr_group (
name varchar(191) NOT NULL,
server_host text NOT NULL,
opts text NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (server_host(191), name)
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE sr_user (
jid varchar(191) NOT NULL,
server_host text NOT NULL,
grp varchar(191) NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (server_host(191), jid, grp)
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE INDEX i_sr_user_sh_jid ON sr_user(server_host(191), jid);
CREATE INDEX i_sr_user_sh_grp ON sr_user(server_host(191), grp);
CREATE TABLE spool (
username varchar(191) NOT NULL,
server_host text NOT NULL,
xml BLOB NOT NULL,
seq BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE INDEX i_spool_sh_username USING BTREE ON spool(server_host(191), username);
CREATE INDEX i_spool_created_at USING BTREE ON spool(created_at);
CREATE TABLE archive (
username varchar(191) NOT NULL,
server_host text NOT NULL,
timestamp BIGINT UNSIGNED NOT NULL,
peer varchar(191) NOT NULL,
bare_peer varchar(191) NOT NULL,
xml text NOT NULL,
txt text,
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE,
kind varchar(10),
nick varchar(191),
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE FULLTEXT INDEX i_text ON archive(txt);
CREATE INDEX i_archive_sh_username_timestamp USING BTREE ON archive(server_host(191), username,timestamp);
CREATE INDEX i_archive_sh_timestamp USING BTREE ON archive(server_host(191), timestamp);
CREATE INDEX i_archive_sh_peer USING BTREE ON archive(server_host(191), peer);
CREATE INDEX i_archive_sh_bare_peer USING BTREE ON archive(server_host(191), bare_peer);
CREATE TABLE archive_prefs (
username varchar(191) NOT NULL,
server_host text NOT NULL,
def text NOT NULL,
always text NOT NULL,
never text NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (server_host(191), username)
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE vcard (
username varchar(191) NOT NULL,
server_host text NOT NULL,
vcard mediumtext NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (server_host(191), username)
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE vcard_search (
username varchar(191) NOT NULL,
lusername varchar(191) NOT NULL,
server_host text NOT NULL,
fn text NOT NULL,
lfn varchar(191) NOT NULL,
family text NOT NULL,
lfamily varchar(191) NOT NULL,
given text NOT NULL,
lgiven varchar(191) NOT NULL,
middle text NOT NULL,
lmiddle varchar(191) NOT NULL,
nickname text NOT NULL,
lnickname varchar(191) NOT NULL,
bday text NOT NULL,
lbday varchar(191) NOT NULL,
ctry text NOT NULL,
lctry varchar(191) NOT NULL,
locality text NOT NULL,
llocality varchar(191) NOT NULL,
email text NOT NULL,
lemail varchar(191) NOT NULL,
orgname text NOT NULL,
lorgname varchar(191) NOT NULL,
orgunit text NOT NULL,
lorgunit varchar(191) NOT NULL,
PRIMARY KEY (server_host(191), lusername)
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE INDEX i_vcard_search_sh_lfn ON vcard_search(server_host(191), lfn);
CREATE INDEX i_vcard_search_sh_lfamily ON vcard_search(server_host(191), lfamily);
CREATE INDEX i_vcard_search_sh_lgiven ON vcard_search(server_host(191), lgiven);
CREATE INDEX i_vcard_search_sh_lmiddle ON vcard_search(server_host(191), lmiddle);
CREATE INDEX i_vcard_search_sh_lnickname ON vcard_search(server_host(191), lnickname);
CREATE INDEX i_vcard_search_sh_lbday ON vcard_search(server_host(191), lbday);
CREATE INDEX i_vcard_search_sh_lctry ON vcard_search(server_host(191), lctry);
CREATE INDEX i_vcard_search_sh_llocality ON vcard_search(server_host(191), llocality);
CREATE INDEX i_vcard_search_sh_lemail ON vcard_search(server_host(191), lemail);
CREATE INDEX i_vcard_search_sh_lorgname ON vcard_search(server_host(191), lorgname);
CREATE INDEX i_vcard_search_sh_lorgunit ON vcard_search(server_host(191), lorgunit);
CREATE TABLE privacy_default_list (
username varchar(191) NOT NULL,
server_host text NOT NULL,
name varchar(191) NOT NULL,
PRIMARY KEY (server_host(191), username)
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE privacy_list (
username varchar(191) NOT NULL,
server_host text NOT NULL,
name varchar(191) NOT NULL,
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT UNIQUE,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE INDEX i_privacy_list_sh_username USING BTREE ON privacy_list(server_host(191), username);
CREATE UNIQUE INDEX i_privacy_list_sh_username_name USING BTREE ON privacy_list (server_host(191), username(75), name(75));
CREATE TABLE privacy_list_data (
id bigint,
t character(1) NOT NULL,
value text NOT NULL,
action character(1) NOT NULL,
ord NUMERIC NOT NULL,
match_all boolean NOT NULL,
match_iq boolean NOT NULL,
match_message boolean NOT NULL,
match_presence_in boolean NOT NULL,
match_presence_out boolean NOT NULL
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE INDEX i_privacy_list_data_id ON privacy_list_data(id);
CREATE TABLE private_storage (
username varchar(191) NOT NULL,
server_host text NOT NULL,
namespace varchar(191) NOT NULL,
data text NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (server_host(191), username, namespace)
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE INDEX i_private_storage_sh_username USING BTREE ON private_storage(server_host(191), username);
-- Not tested in mysql
CREATE TABLE roster_version (
username varchar(191) NOT NULL,
server_host text NOT NULL,
version text NOT NULL,
PRIMARY KEY (server_host(191), username)
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
-- To update from 1.x:
-- ALTER TABLE rosterusers ADD COLUMN askmessage text AFTER ask;
-- UPDATE rosterusers SET askmessage = '';
-- ALTER TABLE rosterusers ALTER COLUMN askmessage SET NOT NULL;
CREATE TABLE pubsub_node (
host text NOT NULL,
node text NOT NULL,
parent VARCHAR(191) NOT NULL DEFAULT '',
plugin text NOT NULL,
nodeid bigint auto_increment primary key
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE INDEX i_pubsub_node_parent ON pubsub_node(parent(120));
CREATE UNIQUE INDEX i_pubsub_node_tuple ON pubsub_node(host(20), node(120));
CREATE TABLE pubsub_node_option (
nodeid bigint,
name text NOT NULL,
val text NOT NULL
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE INDEX i_pubsub_node_option_nodeid ON pubsub_node_option(nodeid);
ALTER TABLE `pubsub_node_option` ADD FOREIGN KEY (`nodeid`) REFERENCES `pubsub_node` (`nodeid`) ON DELETE CASCADE;
CREATE TABLE pubsub_node_owner (
nodeid bigint,
owner text NOT NULL
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE INDEX i_pubsub_node_owner_nodeid ON pubsub_node_owner(nodeid);
ALTER TABLE `pubsub_node_owner` ADD FOREIGN KEY (`nodeid`) REFERENCES `pubsub_node` (`nodeid`) ON DELETE CASCADE;
CREATE TABLE pubsub_state (
nodeid bigint,
jid text NOT NULL,
affiliation character(1),
subscriptions VARCHAR(191) NOT NULL DEFAULT '',
stateid bigint auto_increment primary key
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE INDEX i_pubsub_state_jid ON pubsub_state(jid(60));
CREATE UNIQUE INDEX i_pubsub_state_tuple ON pubsub_state(nodeid, jid(60));
ALTER TABLE `pubsub_state` ADD FOREIGN KEY (`nodeid`) REFERENCES `pubsub_node` (`nodeid`) ON DELETE CASCADE;
CREATE TABLE pubsub_item (
nodeid bigint,
itemid text NOT NULL,
publisher text NOT NULL,
creation text NOT NULL,
modification text NOT NULL,
payload text NOT NULL
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE INDEX i_pubsub_item_itemid ON pubsub_item(itemid(36));
CREATE UNIQUE INDEX i_pubsub_item_tuple ON pubsub_item(nodeid, itemid(36));
ALTER TABLE `pubsub_item` ADD FOREIGN KEY (`nodeid`) REFERENCES `pubsub_node` (`nodeid`) ON DELETE CASCADE;
CREATE TABLE pubsub_subscription_opt (
subid text NOT NULL,
opt_name varchar(32),
opt_value text NOT NULL
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE UNIQUE INDEX i_pubsub_subscription_opt ON pubsub_subscription_opt(subid(32), opt_name(32));
CREATE TABLE muc_room (
name text NOT NULL,
host text NOT NULL,
server_host text NOT NULL,
opts mediumtext NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE UNIQUE INDEX i_muc_room_name_host USING BTREE ON muc_room(name(75), host(75));
CREATE TABLE muc_registered (
jid text NOT NULL,
host text NOT NULL,
server_host text NOT NULL,
nick text NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE INDEX i_muc_registered_nick USING BTREE ON muc_registered(nick(75));
CREATE UNIQUE INDEX i_muc_registered_jid_host USING BTREE ON muc_registered(jid(75), host(75));
CREATE TABLE muc_online_room (
name text NOT NULL,
host text NOT NULL,
server_host text NOT NULL,
node text NOT NULL,
pid text NOT NULL
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE UNIQUE INDEX i_muc_online_room_name_host USING BTREE ON muc_online_room(name(75), host(75));
CREATE TABLE muc_online_users (
username text NOT NULL,
server text NOT NULL,
resource text NOT NULL,
name text NOT NULL,
host text NOT NULL,
server_host text NOT NULL,
node text NOT NULL
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE UNIQUE INDEX i_muc_online_users USING BTREE ON muc_online_users(username(75), server(75), resource(75), name(75), host(75));
CREATE INDEX i_muc_online_users_us USING BTREE ON muc_online_users(username(75), server(75));
CREATE TABLE muc_room_subscribers (
room varchar(191) NOT NULL,
host varchar(191) NOT NULL,
jid varchar(191) NOT NULL,
nick text NOT NULL,
nodes text NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
UNIQUE KEY i_muc_room_subscribers_host_room_jid (host, room, jid)
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE INDEX i_muc_room_subscribers_host_jid USING BTREE ON muc_room_subscribers(host, jid);
CREATE TABLE irc_custom (
jid text NOT NULL,
host text NOT NULL,
server_host text NOT NULL,
data text NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE UNIQUE INDEX i_irc_custom_jid_host USING BTREE ON irc_custom(jid(75), host(75));
CREATE TABLE motd (
username varchar(191) NOT NULL,
server_host text NOT NULL,
xml text,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (server_host(191), username)
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE caps_features (
node varchar(191) NOT NULL,
subnode varchar(191) NOT NULL,
feature text,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE INDEX i_caps_features_node_subnode ON caps_features(node(75), subnode(75));
CREATE TABLE sm (
usec bigint NOT NULL,
pid text NOT NULL,
node text NOT NULL,
username varchar(191) NOT NULL,
server_host text NOT NULL,
resource varchar(191) NOT NULL,
priority text NOT NULL,
info text NOT NULL,
PRIMARY KEY (usec, pid(75))
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE INDEX i_sm_node ON sm(node(75));
CREATE INDEX i_sm_sh_username ON sm(server_host(191), username);
CREATE TABLE oauth_token (
token varchar(191) NOT NULL PRIMARY KEY,
jid text NOT NULL,
scope text NOT NULL,
expire bigint NOT NULL
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE TABLE route (
domain text NOT NULL,
server_host text NOT NULL,
node text NOT NULL,
pid text NOT NULL,
local_hint text NOT NULL
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE UNIQUE INDEX i_route ON route(domain(75), server_host(75), node(75), pid(75));
CREATE INDEX i_route_domain ON route(domain(75));
CREATE TABLE bosh (
sid text NOT NULL,
node text NOT NULL,
pid text NOT NULL
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE UNIQUE INDEX i_bosh_sid ON bosh(sid(75));
CREATE TABLE carboncopy (
username text NOT NULL,
server_host text NOT NULL,
resource text NOT NULL,
namespace text NOT NULL,
node text NOT NULL,
PRIMARY KEY (server_host(191), username(191), resource(191))
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE INDEX i_carboncopy_sh_user ON carboncopy (server_host, username(75));
CREATE TABLE proxy65 (
sid text NOT NULL,
pid_t text NOT NULL,
pid_i text NOT NULL,
node_t text NOT NULL,
node_i text NOT NULL,
jid_i text NOT NULL
) ENGINE=InnoDB CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE UNIQUE INDEX i_proxy65_sid ON proxy65 (sid(191));
CREATE INDEX i_proxy65_jid ON proxy65 (jid_i(191));
CREATE TABLE push_session (
username text NOT NULL,
server_host text NOT NULL,
timestamp bigint NOT NULL,
service text NOT NULL,
node text NOT NULL,
xml text NOT NULL,
PRIMARY KEY (server_host(191), username(191), timestamp)
);
CREATE UNIQUE INDEX i_push_session_susn ON push_session (server_host, username(191), service(191), node(191));
ejabberd-18.01/sql/mssql.sql 0000644 0002322 0002322 00000060154 13225664356 016330 0 ustar debalance debalance --
-- ejabberd, Copyright (C) 2002-2017 ProcessOne
--
-- This program is free software; you can redistribute it and/or
-- modify it under the terms of the GNU General Public License as
-- published by the Free Software Foundation; either version 2 of the
-- License, or (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- General Public License for more details.
--
-- You should have received a copy of the GNU General Public License along
-- with this program; if not, write to the Free Software Foundation, Inc.,
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
--
SET ANSI_PADDING OFF;
SET ANSI_NULLS ON;
SET QUOTED_IDENTIFIER ON;
SET ANSI_PADDING ON;
CREATE TABLE [dbo].[archive] (
[username] [varchar] (250) NOT NULL,
[timestamp] [bigint] NOT NULL,
[peer] [varchar] (250) NOT NULL,
[bare_peer] [varchar] (250) NOT NULL,
[xml] [text] NOT NULL,
[txt] [text] NULL,
[id] [bigint] IDENTITY(1,1) NOT NULL,
[kind] [varchar] (10) NULL,
[nick] [varchar] (250) NULL,
[created_at] [datetime] NOT NULL DEFAULT GETDATE(),
CONSTRAINT [archive_PK] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
) TEXTIMAGE_ON [PRIMARY];
CREATE INDEX [archive_username_timestamp] ON [archive] (username, timestamp)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE INDEX [archive_timestamp] ON [archive] (timestamp)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE INDEX [archive_peer] ON [archive] (peer)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE INDEX [archive_bare_peer] ON [archive] (bare_peer)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE TABLE [dbo].[archive_prefs] (
[username] [varchar] (250) NOT NULL,
[def] [text] NOT NULL,
[always] [text] NOT NULL,
[never] [text] NOT NULL,
[created_at] [datetime] NOT NULL DEFAULT GETDATE(),
CONSTRAINT [archive_prefs_PRIMARY] PRIMARY KEY CLUSTERED
(
[username] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
) TEXTIMAGE_ON [PRIMARY];
CREATE TABLE [dbo].[caps_features] (
[node] [varchar] (250) NOT NULL,
[subnode] [varchar] (250) NOT NULL,
[feature] [text] NULL,
[created_at] [datetime] NOT NULL DEFAULT GETDATE()
) TEXTIMAGE_ON [PRIMARY];
CREATE CLUSTERED INDEX [caps_features_node_subnode] ON [caps_features] (node, subnode)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE TABLE [dbo].[irc_custom] (
[jid] [varchar] (255) NOT NULL,
[host] [varchar] (255) NOT NULL,
[data] [text] NOT NULL,
[created_at] [datetime] NOT NULL DEFAULT GETDATE()
) TEXTIMAGE_ON [PRIMARY];
CREATE UNIQUE CLUSTERED INDEX [irc_custom_jid_host] ON [irc_custom] (jid, host)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE TABLE [dbo].[last] (
[username] [varchar] (250) NOT NULL,
[seconds] [text] NOT NULL,
[state] [text] NOT NULL,
CONSTRAINT [last_PRIMARY] PRIMARY KEY CLUSTERED
(
[username] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
) TEXTIMAGE_ON [PRIMARY];
CREATE TABLE [dbo].[motd] (
[username] [varchar] (250) NOT NULL,
[xml] [text] NULL,
[created_at] [datetime] NOT NULL DEFAULT GETDATE(),
CONSTRAINT [motd_PRIMARY] PRIMARY KEY CLUSTERED
(
[username] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
) TEXTIMAGE_ON [PRIMARY];
CREATE TABLE [dbo].[muc_registered] (
[jid] [varchar] (255) NOT NULL,
[host] [varchar] (255) NOT NULL,
[nick] [varchar] (255) NOT NULL,
[created_at] [datetime] NOT NULL DEFAULT GETDATE()
);
CREATE INDEX [muc_registered_nick] ON [muc_registered] (nick)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE UNIQUE CLUSTERED INDEX [muc_registered_jid_host] ON [muc_registered] (jid, host)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE TABLE [dbo].[muc_room] (
[name] [varchar] (250) NOT NULL,
[host] [varchar] (250) NOT NULL,
[opts] [text] NOT NULL,
[created_at] [datetime] NOT NULL DEFAULT GETDATE()
) TEXTIMAGE_ON [PRIMARY];
CREATE UNIQUE CLUSTERED INDEX [muc_room_name_host] ON [muc_room] (name, host)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE TABLE [dbo].[muc_online_room] (
[name] [varchar] (250) NOT NULL,
[host] [varchar] (250) NOT NULL,
[node] [text] NOT NULL,
[pid] [text] NOT NULL
);
CREATE UNIQUE CLUSTERED INDEX [muc_online_room_name_host] ON [muc_online_room] (name, host)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE TABLE [dbo].[muc_online_users] (
[username] [varchar] (250) NOT NULL,
[server] [varchar] (250) NOT NULL,
[resource] [varchar] (250) NOT NULL,
[name] [varchar] (250) NOT NULL,
[host] [varchar] (250) NOT NULL,
node text NOT NULL
);
CREATE UNIQUE CLUSTERED INDEX [muc_online_users_i] ON [muc_online_users] (username, server, resource, name, host)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE UNIQUE CLUSTERED INDEX [muc_online_users_us] ON [muc_online_users] (username, server);
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE TABLE [dbo].[muc_room_subscribers] (
[room] [varchar] (191) NOT NULL,
[host] [varchar] (191) NOT NULL,
[jid] [varchar] (191) NOT NULL,
[nick] [text] NOT NULL,
[nodes] [text] NOT NULL,
[created_at] [datetime] NOT NULL DEFAULT GETDATE()
);
CREATE UNIQUE CLUSTERED INDEX [muc_room_subscribers_host_room_jid] ON [muc_room_subscribers] (host, room, jid);
CREATE INDEX [muc_room_subscribers_host_jid] ON [muc_room_subscribers] (host, jid);
CREATE TABLE [dbo].[privacy_default_list] (
[username] [varchar] (250) NOT NULL,
[name] [varchar] (250) NOT NULL,
CONSTRAINT [privacy_default_list_PRIMARY] PRIMARY KEY CLUSTERED
(
[username] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
);
CREATE TABLE [dbo].[privacy_list] (
[username] [varchar] (250) NOT NULL,
[name] [varchar] (250) NOT NULL,
[id] [bigint] IDENTITY(1,1) NOT NULL,
[created_at] [datetime] NOT NULL DEFAULT GETDATE(),
CONSTRAINT [privacy_list_PK] PRIMARY KEY CLUSTERED
(
[id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
);
CREATE INDEX [privacy_list_username] ON [privacy_list] (username)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE UNIQUE INDEX [privacy_list_username_name] ON [privacy_list] (username, name)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE TABLE [dbo].[privacy_list_data] (
[id] [bigint] NULL,
[t] [char] (1) NOT NULL,
[value] [text] NOT NULL,
[action] [char] (1) NOT NULL,
[ord] [smallint] NOT NULL,
[match_all] [smallint] NOT NULL,
[match_iq] [smallint] NOT NULL,
[match_message] [smallint] NOT NULL,
[match_presence_in] [smallint] NOT NULL,
[match_presence_out] [smallint] NOT NULL
) TEXTIMAGE_ON [PRIMARY];
CREATE CLUSTERED INDEX [privacy_list_data_id] ON [privacy_list_data] (id)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE TABLE [dbo].[private_storage] (
[username] [varchar] (250) NOT NULL,
[namespace] [varchar] (250) NOT NULL,
[data] [text] NOT NULL,
[created_at] [datetime] NOT NULL DEFAULT GETDATE()
) TEXTIMAGE_ON [PRIMARY];
CREATE INDEX [private_storage_username] ON [private_storage] (username)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE UNIQUE CLUSTERED INDEX [private_storage_username_namespace] ON [private_storage] (username, namespace)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE TABLE [dbo].[pubsub_item] (
[nodeid] [bigint] NULL,
[itemid] [varchar] (255) NOT NULL,
[publisher] [text] NOT NULL,
[creation] [text] NOT NULL,
[modification] [varchar] (255) NOT NULL,
[payload] [text] NOT NULL DEFAULT ''
) TEXTIMAGE_ON [PRIMARY];
CREATE INDEX [pubsub_item_itemid] ON [pubsub_item] (itemid)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE UNIQUE CLUSTERED INDEX [pubsub_item_nodeid_itemid] ON [pubsub_item] (nodeid, itemid)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE TABLE [dbo].[pubsub_node_option] (
[nodeid] [bigint] NULL,
[name] [text] NOT NULL,
[val] [text] NOT NULL
) TEXTIMAGE_ON [PRIMARY];
CREATE CLUSTERED INDEX [pubsub_node_option_nodeid] ON [pubsub_node_option] (nodeid)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE TABLE [dbo].[pubsub_node_owner] (
[nodeid] [bigint] NULL,
[owner] [text] NOT NULL
) TEXTIMAGE_ON [PRIMARY];
CREATE CLUSTERED INDEX [pubsub_node_owner_nodeid] ON [pubsub_node_owner] (nodeid)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE TABLE [dbo].[pubsub_state] (
[nodeid] [bigint] NULL,
[jid] [varchar] (255) NOT NULL,
[affiliation] [char] (1) NOT NULL,
[subscriptions] [text] NOT NULL DEFAULT '',
[stateid] [bigint] IDENTITY(1,1) NOT NULL,
CONSTRAINT [pubsub_state_PRIMARY] PRIMARY KEY CLUSTERED
(
[stateid] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
) TEXTIMAGE_ON [PRIMARY];
CREATE INDEX [pubsub_state_jid] ON [pubsub_state] (jid)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE UNIQUE INDEX [pubsub_state_nodeid_jid] ON [pubsub_state] (nodeid, jid)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE TABLE [dbo].[pubsub_subscription_opt] (
[subid] [varchar] (255) NOT NULL,
[opt_name] [varchar] (32) NOT NULL,
[opt_value] [text] NOT NULL
) TEXTIMAGE_ON [PRIMARY];
CREATE UNIQUE CLUSTERED INDEX [pubsub_subscription_opt_subid_opt_name] ON [pubsub_subscription_opt] (subid, opt_name)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE TABLE [dbo].[pubsub_node] (
[host] [varchar] (255) NOT NULL,
[node] [varchar] (255) NOT NULL,
[parent] [varchar] (255) NOT NULL DEFAULT '',
[plugin] [text] NOT NULL,
[nodeid] [bigint] IDENTITY(1,1) NOT NULL,
CONSTRAINT [pubsub_node_PRIMARY] PRIMARY KEY CLUSTERED
(
[nodeid] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
) TEXTIMAGE_ON [PRIMARY];
CREATE INDEX [pubsub_node_parent] ON [pubsub_node] (parent)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE UNIQUE INDEX [pubsub_node_host_node] ON [pubsub_node] (host, node)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE TABLE [dbo].[roster_version] (
[username] [varchar] (250) NOT NULL,
[version] [text] NOT NULL,
CONSTRAINT [roster_version_PRIMARY] PRIMARY KEY CLUSTERED
(
[username] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
) TEXTIMAGE_ON [PRIMARY];
CREATE TABLE [dbo].[rostergroups] (
[username] [varchar] (250) NOT NULL,
[jid] [varchar] (250) NOT NULL,
[grp] [text] NOT NULL
) TEXTIMAGE_ON [PRIMARY];
CREATE CLUSTERED INDEX [rostergroups_username_jid] ON [rostergroups] ([username], [jid])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE TABLE [dbo].[rosterusers] (
[username] [varchar] (250) NOT NULL,
[jid] [varchar] (250) NOT NULL,
[nick] [text] NOT NULL,
[subscription] [char] (1) NOT NULL,
[ask] [char] (1) NOT NULL,
[askmessage] [text] NOT NULL,
[server] [char] (1) NOT NULL,
[subscribe] [text] NOT NULL,
[type] [text] NULL,
[created_at] [datetime] NOT NULL DEFAULT GETDATE()
) TEXTIMAGE_ON [PRIMARY];
CREATE UNIQUE CLUSTERED INDEX [rosterusers_username_jid] ON [rosterusers] ([username], [jid])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE INDEX [rosterusers_username] ON [rosterusers] ([username])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE INDEX [rosterusers_jid] ON [rosterusers] ([jid])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE TABLE [dbo].[sm] (
[usec] [bigint] NOT NULL,
[pid] [varchar] (100) NOT NULL,
[node] [varchar] (255) NOT NULL,
[username] [varchar] (255) NOT NULL,
[resource] [varchar] (255) NOT NULL,
[priority] [text] NOT NULL,
[info] [text] NOT NULL
) TEXTIMAGE_ON [PRIMARY];
CREATE UNIQUE CLUSTERED INDEX [sm_sid] ON [sm] (usec, pid)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE INDEX [sm_node] ON [sm] (node)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE INDEX [sm_username] ON [sm] (username)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE TABLE [dbo].[spool] (
[username] [varchar] (250) NOT NULL,
[xml] [text] NOT NULL,
[seq] [bigint] IDENTITY(1,1) NOT NULL,
[created_at] [datetime] NOT NULL DEFAULT GETDATE(),
CONSTRAINT [spool_PK] PRIMARY KEY CLUSTERED
(
[seq] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
) TEXTIMAGE_ON [PRIMARY];
CREATE INDEX [spool_username] ON [spool] (username)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE INDEX [spool_created_at] ON [spool] (created_at)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
;
CREATE TABLE [dbo].[sr_group] (
[name] [varchar] (250) NOT NULL,
[opts] [text] NOT NULL,
[created_at] [datetime] NOT NULL DEFAULT GETDATE(),
CONSTRAINT [sr_group_PRIMARY] PRIMARY KEY CLUSTERED
(
[name] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
) TEXTIMAGE_ON [PRIMARY];
CREATE TABLE [dbo].[sr_user] (
[jid] [varchar] (250) NOT NULL,
[grp] [varchar] (250) NOT NULL,
[created_at] [datetime] NOT NULL DEFAULT GETDATE()
);
CREATE UNIQUE CLUSTERED INDEX [sr_user_jid_group] ON [sr_user] ([jid], [grp])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE INDEX [sr_user_jid] ON [sr_user] ([jid])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE INDEX [sr_user_grp] ON [sr_user] ([grp])
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE TABLE [dbo].[users] (
[username] [varchar] (250) NOT NULL,
[password] [text] NOT NULL,
[serverkey] [text] NOT NULL DEFAULT '',
[salt] [text] NOT NULL DEFAULT '',
[iterationcount] [smallint] NOT NULL DEFAULT 0,
[created_at] [datetime] NOT NULL DEFAULT GETDATE(),
CONSTRAINT [users_PRIMARY] PRIMARY KEY CLUSTERED
(
[username] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
) TEXTIMAGE_ON [PRIMARY];
CREATE TABLE [dbo].[vcard] (
[username] [varchar] (250) NOT NULL,
[vcard] [text] NOT NULL,
[created_at] [datetime] NOT NULL DEFAULT GETDATE(),
CONSTRAINT [vcard_PRIMARY] PRIMARY KEY CLUSTERED
(
[username] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
) TEXTIMAGE_ON [PRIMARY];
CREATE TABLE [dbo].[vcard_search] (
[username] [varchar] (250) NOT NULL,
[lusername] [varchar] (250) NOT NULL,
[fn] [text] NOT NULL,
[lfn] [varchar] (250) NOT NULL,
[family] [text] NOT NULL,
[lfamily] [varchar] (250) NOT NULL,
[given] [text] NOT NULL,
[lgiven] [varchar] (250) NOT NULL,
[middle] [text] NOT NULL,
[lmiddle] [varchar] (250) NOT NULL,
[nickname] [text] NOT NULL,
[lnickname] [varchar] (250) NOT NULL,
[bday] [text] NOT NULL,
[lbday] [varchar] (250) NOT NULL,
[ctry] [text] NOT NULL,
[lctry] [varchar] (250) NOT NULL,
[locality] [text] NOT NULL,
[llocality] [varchar] (250) NOT NULL,
[email] [text] NOT NULL,
[lemail] [varchar] (250) NOT NULL,
[orgname] [text] NOT NULL,
[lorgname] [varchar] (250) NOT NULL,
[orgunit] [text] NOT NULL,
[lorgunit] [varchar] (250) NOT NULL,
CONSTRAINT [vcard_search_PRIMARY] PRIMARY KEY CLUSTERED
(
[lusername] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
) TEXTIMAGE_ON [PRIMARY];
CREATE INDEX [vcard_search_lfn] ON [vcard_search] (lfn)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE INDEX [vcard_search_lfamily] ON [vcard_search] (lfamily)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE INDEX [vcard_search_lgiven] ON [vcard_search] (lgiven)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE INDEX [vcard_search_lmiddle] ON [vcard_search] (lmiddle)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE INDEX [vcard_search_lnickname] ON [vcard_search] (lnickname)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE INDEX [vcard_search_lbday] ON [vcard_search] (lbday)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE INDEX [vcard_search_lctry] ON [vcard_search] (lctry)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE INDEX [vcard_search_llocality] ON [vcard_search] (llocality)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE INDEX [vcard_search_lemail] ON [vcard_search] (lemail)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE INDEX [vcard_search_lorgname] ON [vcard_search] (lorgname)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE INDEX [vcard_search_lorgunit] ON [vcard_search] (lorgunit)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
ALTER TABLE [dbo].[pubsub_item] WITH CHECK ADD CONSTRAINT [pubsub_item_ibfk_1] FOREIGN KEY([nodeid])
REFERENCES [dbo].[pubsub_node] ([nodeid])
ON DELETE CASCADE;
ALTER TABLE [dbo].[pubsub_item] CHECK CONSTRAINT [pubsub_item_ibfk_1];
ALTER TABLE [dbo].[pubsub_node_option] WITH CHECK ADD CONSTRAINT [pubsub_node_option_ibfk_1] FOREIGN KEY([nodeid])
REFERENCES [dbo].[pubsub_node] ([nodeid])
ON DELETE CASCADE;
ALTER TABLE [dbo].[pubsub_node_option] CHECK CONSTRAINT [pubsub_node_option_ibfk_1];
ALTER TABLE [dbo].[pubsub_node_owner] WITH CHECK ADD CONSTRAINT [pubsub_node_owner_ibfk_1] FOREIGN KEY([nodeid])
REFERENCES [dbo].[pubsub_node] ([nodeid])
ON DELETE CASCADE;
ALTER TABLE [dbo].[pubsub_node_owner] CHECK CONSTRAINT [pubsub_node_owner_ibfk_1];
ALTER TABLE [dbo].[pubsub_state] WITH CHECK ADD CONSTRAINT [pubsub_state_ibfk_1] FOREIGN KEY([nodeid])
REFERENCES [dbo].[pubsub_node] ([nodeid])
ON DELETE CASCADE;
ALTER TABLE [dbo].[pubsub_state] CHECK CONSTRAINT [pubsub_state_ibfk_1];
CREATE TABLE [dbo].[oauth_token] (
[token] [varchar] (250) NOT NULL,
[jid] [text] NOT NULL,
[scope] [text] NOT NULL,
[expire] [bigint] NOT NULL,
CONSTRAINT [oauth_token_PRIMARY] PRIMARY KEY CLUSTERED
(
[token] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
) TEXTIMAGE_ON [PRIMARY];
CREATE TABLE [dbo].[route] (
[domain] [varchar] (255) NOT NULL,
[server_host] [varchar] (255) NOT NULL,
[node] [varchar] (255) NOT NULL,
[pid] [varchar](100) NOT NULL,
[local_hint] [text] NOT NULL
);
CREATE UNIQUE CLUSTERED INDEX [route_i] ON [route] (domain, server_host, node, pid)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE INDEX [route_domain] ON [route] (domain)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE TABLE [dbo].[bosh] (
[sid] [varchar] (255) NOT NULL,
[node] [varchar] (255) NOT NULL,
[pid] [varchar](100) NOT NULL
CONSTRAINT [bosh_PRIMARY] PRIMARY KEY CLUSTERED
(
[sid] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON)
) TEXTIMAGE_ON [PRIMARY];
CREATE TABLE [dbo].[carboncopy] (
[username] [varchar] (255) NOT NULL,
[resource] [varchar] (255) NOT NULL,
[namespace] [varchar] (255) NOT NULL,
[node] [varchar] (255) NOT NULL
);
CREATE UNIQUE CLUSTERED INDEX [carboncopy_ur] ON [carboncopy] (username, resource)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE INDEX [carboncopy_user] ON [carboncopy] (username)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE TABLE [dbo].[push_session] (
[username] [varchar] (255) NOT NULL,
[timestamp] [bigint] NOT NULL,
[service] [varchar] (255) NOT NULL,
[node] [varchar] (255) NOT NULL,
[xml] [varchar] (255) NOT NULL
);
CREATE UNIQUE CLUSTERED INDEX [i_push_usn] ON [push_session] (username, service, node)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
CREATE UNIQUE CLUSTERED INDEX [i_push_ut] ON [push_session] (username, timestamp)
WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON);
ejabberd-18.01/sql/pg.sql 0000644 0002322 0002322 00000030525 13225664356 015576 0 ustar debalance debalance --
-- ejabberd, Copyright (C) 2002-2017 ProcessOne
--
-- This program is free software; you can redistribute it and/or
-- modify it under the terms of the GNU General Public License as
-- published by the Free Software Foundation; either version 2 of the
-- License, or (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- General Public License for more details.
--
-- You should have received a copy of the GNU General Public License along
-- with this program; if not, write to the Free Software Foundation, Inc.,
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
--
CREATE TABLE users (
username text PRIMARY KEY,
"password" text NOT NULL,
serverkey text NOT NULL DEFAULT '',
salt text NOT NULL DEFAULT '',
iterationcount integer NOT NULL DEFAULT 0,
created_at TIMESTAMP NOT NULL DEFAULT now()
);
-- Add support for SCRAM auth to a database created before ejabberd 16.03:
-- ALTER TABLE users ADD COLUMN serverkey text NOT NULL DEFAULT '';
-- ALTER TABLE users ADD COLUMN salt text NOT NULL DEFAULT '';
-- ALTER TABLE users ADD COLUMN iterationcount integer NOT NULL DEFAULT 0;
CREATE TABLE last (
username text PRIMARY KEY,
seconds text NOT NULL,
state text NOT NULL
);
CREATE TABLE rosterusers (
username text NOT NULL,
jid text NOT NULL,
nick text NOT NULL,
subscription character(1) NOT NULL,
ask character(1) NOT NULL,
askmessage text NOT NULL,
server character(1) NOT NULL,
subscribe text NOT NULL,
"type" text,
created_at TIMESTAMP NOT NULL DEFAULT now()
);
CREATE UNIQUE INDEX i_rosteru_user_jid ON rosterusers USING btree (username, jid);
CREATE INDEX i_rosteru_username ON rosterusers USING btree (username);
CREATE INDEX i_rosteru_jid ON rosterusers USING btree (jid);
CREATE TABLE rostergroups (
username text NOT NULL,
jid text NOT NULL,
grp text NOT NULL
);
CREATE INDEX pk_rosterg_user_jid ON rostergroups USING btree (username, jid);
CREATE TABLE sr_group (
name text NOT NULL,
opts text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT now()
);
CREATE TABLE sr_user (
jid text NOT NULL,
grp text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT now()
);
CREATE UNIQUE INDEX i_sr_user_jid_grp ON sr_user USING btree (jid, grp);
CREATE INDEX i_sr_user_jid ON sr_user USING btree (jid);
CREATE INDEX i_sr_user_grp ON sr_user USING btree (grp);
CREATE TABLE spool (
username text NOT NULL,
xml text NOT NULL,
seq SERIAL,
created_at TIMESTAMP NOT NULL DEFAULT now()
);
CREATE INDEX i_despool ON spool USING btree (username);
CREATE TABLE archive (
username text NOT NULL,
timestamp BIGINT NOT NULL,
peer text NOT NULL,
bare_peer text NOT NULL,
xml text NOT NULL,
txt text,
id SERIAL,
kind text,
nick text,
created_at TIMESTAMP NOT NULL DEFAULT now()
);
CREATE INDEX i_username_timestamp ON archive USING btree (username, timestamp);
CREATE INDEX i_timestamp ON archive USING btree (timestamp);
CREATE INDEX i_peer ON archive USING btree (peer);
CREATE INDEX i_bare_peer ON archive USING btree (bare_peer);
CREATE TABLE archive_prefs (
username text NOT NULL PRIMARY KEY,
def text NOT NULL,
always text NOT NULL,
never text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT now()
);
CREATE TABLE vcard (
username text PRIMARY KEY,
vcard text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT now()
);
CREATE TABLE vcard_search (
username text NOT NULL,
lusername text PRIMARY KEY,
fn text NOT NULL,
lfn text NOT NULL,
family text NOT NULL,
lfamily text NOT NULL,
given text NOT NULL,
lgiven text NOT NULL,
middle text NOT NULL,
lmiddle text NOT NULL,
nickname text NOT NULL,
lnickname text NOT NULL,
bday text NOT NULL,
lbday text NOT NULL,
ctry text NOT NULL,
lctry text NOT NULL,
locality text NOT NULL,
llocality text NOT NULL,
email text NOT NULL,
lemail text NOT NULL,
orgname text NOT NULL,
lorgname text NOT NULL,
orgunit text NOT NULL,
lorgunit text NOT NULL
);
CREATE INDEX i_vcard_search_lfn ON vcard_search(lfn);
CREATE INDEX i_vcard_search_lfamily ON vcard_search(lfamily);
CREATE INDEX i_vcard_search_lgiven ON vcard_search(lgiven);
CREATE INDEX i_vcard_search_lmiddle ON vcard_search(lmiddle);
CREATE INDEX i_vcard_search_lnickname ON vcard_search(lnickname);
CREATE INDEX i_vcard_search_lbday ON vcard_search(lbday);
CREATE INDEX i_vcard_search_lctry ON vcard_search(lctry);
CREATE INDEX i_vcard_search_llocality ON vcard_search(llocality);
CREATE INDEX i_vcard_search_lemail ON vcard_search(lemail);
CREATE INDEX i_vcard_search_lorgname ON vcard_search(lorgname);
CREATE INDEX i_vcard_search_lorgunit ON vcard_search(lorgunit);
CREATE TABLE privacy_default_list (
username text PRIMARY KEY,
name text NOT NULL
);
CREATE TABLE privacy_list (
username text NOT NULL,
name text NOT NULL,
id SERIAL UNIQUE,
created_at TIMESTAMP NOT NULL DEFAULT now()
);
CREATE INDEX i_privacy_list_username ON privacy_list USING btree (username);
CREATE UNIQUE INDEX i_privacy_list_username_name ON privacy_list USING btree (username, name);
CREATE TABLE privacy_list_data (
id bigint REFERENCES privacy_list(id) ON DELETE CASCADE,
t character(1) NOT NULL,
value text NOT NULL,
action character(1) NOT NULL,
ord NUMERIC NOT NULL,
match_all boolean NOT NULL,
match_iq boolean NOT NULL,
match_message boolean NOT NULL,
match_presence_in boolean NOT NULL,
match_presence_out boolean NOT NULL
);
CREATE INDEX i_privacy_list_data_id ON privacy_list_data USING btree (id);
CREATE TABLE private_storage (
username text NOT NULL,
namespace text NOT NULL,
data text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT now()
);
CREATE INDEX i_private_storage_username ON private_storage USING btree (username);
CREATE UNIQUE INDEX i_private_storage_username_namespace ON private_storage USING btree (username, namespace);
CREATE TABLE roster_version (
username text PRIMARY KEY,
version text NOT NULL
);
-- To update from 0.9.8:
-- CREATE SEQUENCE spool_seq_seq;
-- ALTER TABLE spool ADD COLUMN seq integer;
-- ALTER TABLE spool ALTER COLUMN seq SET DEFAULT nextval('spool_seq_seq');
-- UPDATE spool SET seq = DEFAULT;
-- ALTER TABLE spool ALTER COLUMN seq SET NOT NULL;
-- To update from 1.x:
-- ALTER TABLE rosterusers ADD COLUMN askmessage text;
-- UPDATE rosterusers SET askmessage = '';
-- ALTER TABLE rosterusers ALTER COLUMN askmessage SET NOT NULL;
CREATE TABLE pubsub_node (
host text NOT NULL,
node text NOT NULL,
parent text NOT NULL DEFAULT '',
plugin text NOT NULL,
nodeid SERIAL UNIQUE
);
CREATE INDEX i_pubsub_node_parent ON pubsub_node USING btree (parent);
CREATE UNIQUE INDEX i_pubsub_node_tuple ON pubsub_node USING btree (host, node);
CREATE TABLE pubsub_node_option (
nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE,
name text NOT NULL,
val text NOT NULL
);
CREATE INDEX i_pubsub_node_option_nodeid ON pubsub_node_option USING btree (nodeid);
CREATE TABLE pubsub_node_owner (
nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE,
owner text NOT NULL
);
CREATE INDEX i_pubsub_node_owner_nodeid ON pubsub_node_owner USING btree (nodeid);
CREATE TABLE pubsub_state (
nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE,
jid text NOT NULL,
affiliation character(1),
subscriptions text NOT NULL DEFAULT '',
stateid SERIAL UNIQUE
);
CREATE INDEX i_pubsub_state_jid ON pubsub_state USING btree (jid);
CREATE UNIQUE INDEX i_pubsub_state_tuple ON pubsub_state USING btree (nodeid, jid);
CREATE TABLE pubsub_item (
nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE,
itemid text NOT NULL,
publisher text NOT NULL,
creation text NOT NULL,
modification text NOT NULL,
payload text NOT NULL DEFAULT ''
);
CREATE INDEX i_pubsub_item_itemid ON pubsub_item USING btree (itemid);
CREATE UNIQUE INDEX i_pubsub_item_tuple ON pubsub_item USING btree (nodeid, itemid);
CREATE TABLE pubsub_subscription_opt (
subid text NOT NULL,
opt_name varchar(32),
opt_value text NOT NULL
);
CREATE UNIQUE INDEX i_pubsub_subscription_opt ON pubsub_subscription_opt USING btree (subid, opt_name);
CREATE TABLE muc_room (
name text NOT NULL,
host text NOT NULL,
opts text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT now()
);
CREATE UNIQUE INDEX i_muc_room_name_host ON muc_room USING btree (name, host);
CREATE TABLE muc_registered (
jid text NOT NULL,
host text NOT NULL,
nick text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT now()
);
CREATE INDEX i_muc_registered_nick ON muc_registered USING btree (nick);
CREATE UNIQUE INDEX i_muc_registered_jid_host ON muc_registered USING btree (jid, host);
CREATE TABLE muc_online_room (
name text NOT NULL,
host text NOT NULL,
node text NOT NULL,
pid text NOT NULL
);
CREATE UNIQUE INDEX i_muc_online_room_name_host ON muc_online_room USING btree (name, host);
CREATE TABLE muc_online_users (
username text NOT NULL,
server text NOT NULL,
resource text NOT NULL,
name text NOT NULL,
host text NOT NULL,
node text NOT NULL
);
CREATE UNIQUE INDEX i_muc_online_users ON muc_online_users USING btree (username, server, resource, name, host);
CREATE INDEX i_muc_online_users_us ON muc_online_users USING btree (username, server);
CREATE TABLE muc_room_subscribers (
room text NOT NULL,
host text NOT NULL,
jid text NOT NULL,
nick text NOT NULL,
nodes text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT now()
);
CREATE INDEX i_muc_room_subscribers_host_jid ON muc_room_subscribers USING btree (host, jid);
CREATE UNIQUE INDEX i_muc_room_subscribers_host_room_jid ON muc_room_subscribers USING btree (host, room, jid);
CREATE TABLE irc_custom (
jid text NOT NULL,
host text NOT NULL,
data text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT now()
);
CREATE UNIQUE INDEX i_irc_custom_jid_host ON irc_custom USING btree (jid, host);
CREATE TABLE motd (
username text PRIMARY KEY,
xml text,
created_at TIMESTAMP NOT NULL DEFAULT now()
);
CREATE TABLE caps_features (
node text NOT NULL,
subnode text NOT NULL,
feature text,
created_at TIMESTAMP NOT NULL DEFAULT now()
);
CREATE INDEX i_caps_features_node_subnode ON caps_features USING btree (node, subnode);
CREATE TABLE sm (
usec bigint NOT NULL,
pid text NOT NULL,
node text NOT NULL,
username text NOT NULL,
resource text NOT NULL,
priority text NOT NULL,
info text NOT NULL
);
CREATE UNIQUE INDEX i_sm_sid ON sm USING btree (usec, pid);
CREATE INDEX i_sm_node ON sm USING btree (node);
CREATE INDEX i_sm_username ON sm USING btree (username);
CREATE TABLE oauth_token (
token text NOT NULL,
jid text NOT NULL,
scope text NOT NULL,
expire bigint NOT NULL
);
CREATE UNIQUE INDEX i_oauth_token_token ON oauth_token USING btree (token);
CREATE TABLE route (
domain text NOT NULL,
server_host text NOT NULL,
node text NOT NULL,
pid text NOT NULL,
local_hint text NOT NULL
);
CREATE UNIQUE INDEX i_route ON route USING btree (domain, server_host, node, pid);
CREATE INDEX i_route_domain ON route USING btree (domain);
CREATE TABLE bosh (
sid text NOT NULL,
node text NOT NULL,
pid text NOT NULL
);
CREATE UNIQUE INDEX i_bosh_sid ON bosh USING btree (sid);
CREATE TABLE carboncopy (
username text NOT NULL,
resource text NOT NULL,
namespace text NOT NULL,
node text NOT NULL
);
CREATE UNIQUE INDEX i_carboncopy_ur ON carboncopy USING btree (username, resource);
CREATE INDEX i_carboncopy_user ON carboncopy USING btree (username);
CREATE TABLE proxy65 (
sid text NOT NULL,
pid_t text NOT NULL,
pid_i text NOT NULL,
node_t text NOT NULL,
node_i text NOT NULL,
jid_i text NOT NULL
);
CREATE UNIQUE INDEX i_proxy65_sid ON proxy65 USING btree (sid);
CREATE INDEX i_proxy65_jid ON proxy65 USING btree (jid_i);
CREATE TABLE push_session (
username text NOT NULL,
timestamp bigint NOT NULL,
service text NOT NULL,
node text NOT NULL,
xml text NOT NULL
);
CREATE UNIQUE INDEX i_push_usn ON push_session USING btree (username, service, node);
CREATE UNIQUE INDEX i_push_ut ON push_session USING btree (username, timestamp);
ejabberd-18.01/sql/lite.new.sql 0000644 0002322 0002322 00000031213 13225664356 016710 0 ustar debalance debalance --
-- ejabberd, Copyright (C) 2002-2017 ProcessOne
--
-- This program is free software; you can redistribute it and/or
-- modify it under the terms of the GNU General Public License as
-- published by the Free Software Foundation; either version 2 of the
-- License, or (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-- General Public License for more details.
--
-- You should have received a copy of the GNU General Public License along
-- with this program; if not, write to the Free Software Foundation, Inc.,
-- 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
--
CREATE TABLE users (
username text NOT NULL,
server_host text NOT NULL,
password text NOT NULL,
serverkey text NOT NULL DEFAULT '',
salt text NOT NULL DEFAULT '',
iterationcount integer NOT NULL DEFAULT 0,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (server_host, username)
);
CREATE TABLE last (
username text NOT NULL,
server_host text NOT NULL,
seconds text NOT NULL,
state text NOT NULL,
PRIMARY KEY (server_host, username)
);
CREATE TABLE rosterusers (
username text NOT NULL,
server_host text NOT NULL,
jid text NOT NULL,
nick text NOT NULL,
subscription character(1) NOT NULL,
ask character(1) NOT NULL,
askmessage text NOT NULL,
server character(1) NOT NULL,
subscribe text NOT NULL,
type text,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE UNIQUE INDEX i_rosteru_sh_user_jid ON rosterusers (server_host, username, jid);
CREATE INDEX i_rosteru_sh_username ON rosterusers (server_host, username);
CREATE INDEX i_rosteru_sh_jid ON rosterusers (server_host, jid);
CREATE TABLE rostergroups (
username text NOT NULL,
server_host text NOT NULL,
jid text NOT NULL,
grp text NOT NULL
);
CREATE INDEX i_rosterg_sh_user_jid ON rostergroups (server_host, username, jid);
CREATE TABLE sr_group (
name text NOT NULL,
server_host text NOT NULL,
opts text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (server_host, name)
);
CREATE TABLE sr_user (
jid text NOT NULL,
server_host text NOT NULL,
grp text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (server_host, jid, grp)
);
CREATE INDEX i_sr_user_sh_jid ON sr_user (server_host, jid);
CREATE INDEX i_sr_user_sh_grp ON sr_user (server_host, grp);
CREATE TABLE spool (
username text NOT NULL,
server_host text NOT NULL,
xml text NOT NULL,
seq INTEGER PRIMARY KEY AUTOINCREMENT,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX i_spool_sh_username ON spool (server_host, username);
CREATE TABLE archive (
username text NOT NULL,
server_host text NOT NULL,
timestamp BIGINT UNSIGNED NOT NULL,
peer text NOT NULL,
bare_peer text NOT NULL,
xml text NOT NULL,
txt text,
id INTEGER PRIMARY KEY AUTOINCREMENT,
kind text,
nick text,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX i_archive_sh_username_timestamp ON archive (server_host, username, timestamp);
CREATE INDEX i_archive_sh_timestamp ON archive (server_host, timestamp);
CREATE INDEX i_archive_sh_peer ON archive (server_host, peer);
CREATE INDEX i_archive_sh_bare_peer ON archive (server_host, bare_peer);
CREATE TABLE archive_prefs (
username text NOT NULL,
server_host text NOT NULL,
def text NOT NULL,
always text NOT NULL,
never text NOT NULL,
created_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (server_host, username)
);
CREATE TABLE vcard (
username text NOT NULL,
server_host text NOT NULL,
vcard text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (server_host, username)
);
CREATE TABLE vcard_search (
username text NOT NULL,
lusername text NOT NULL,
server_host text NOT NULL,
fn text NOT NULL,
lfn text NOT NULL,
family text NOT NULL,
lfamily text NOT NULL,
given text NOT NULL,
lgiven text NOT NULL,
middle text NOT NULL,
lmiddle text NOT NULL,
nickname text NOT NULL,
lnickname text NOT NULL,
bday text NOT NULL,
lbday text NOT NULL,
ctry text NOT NULL,
lctry text NOT NULL,
locality text NOT NULL,
llocality text NOT NULL,
email text NOT NULL,
lemail text NOT NULL,
orgname text NOT NULL,
lorgname text NOT NULL,
orgunit text NOT NULL,
lorgunit text NOT NULL,
PRIMARY KEY (server_host, lusername)
);
CREATE INDEX i_vcard_search_sh_lfn ON vcard_search(server_host, lfn);
CREATE INDEX i_vcard_search_sh_lfamily ON vcard_search(server_host, lfamily);
CREATE INDEX i_vcard_search_sh_lgiven ON vcard_search(server_host, lgiven);
CREATE INDEX i_vcard_search_sh_lmiddle ON vcard_search(server_host, lmiddle);
CREATE INDEX i_vcard_search_sh_lnickname ON vcard_search(server_host, lnickname);
CREATE INDEX i_vcard_search_sh_lbday ON vcard_search(server_host, lbday);
CREATE INDEX i_vcard_search_sh_lctry ON vcard_search(server_host, lctry);
CREATE INDEX i_vcard_search_sh_llocality ON vcard_search(server_host, llocality);
CREATE INDEX i_vcard_search_sh_lemail ON vcard_search(server_host, lemail);
CREATE INDEX i_vcard_search_sh_lorgname ON vcard_search(server_host, lorgname);
CREATE INDEX i_vcard_search_sh_lorgunit ON vcard_search(server_host, lorgunit);
CREATE TABLE privacy_default_list (
username text NOT NULL,
server_host text NOT NULL,
name text NOT NULL,
PRIMARY KEY (server_host, username)
);
CREATE TABLE privacy_list (
username text NOT NULL,
server_host text NOT NULL,
name text NOT NULL,
id INTEGER PRIMARY KEY AUTOINCREMENT,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX i_privacy_list_sh_username ON privacy_list (server_host, username);
CREATE UNIQUE INDEX i_privacy_list_sh_username_name ON privacy_list (server_host, username, name);
CREATE TABLE privacy_list_data (
id bigint REFERENCES privacy_list(id) ON DELETE CASCADE,
t character(1) NOT NULL,
value text NOT NULL,
action character(1) NOT NULL,
ord NUMERIC NOT NULL,
match_all boolean NOT NULL,
match_iq boolean NOT NULL,
match_message boolean NOT NULL,
match_presence_in boolean NOT NULL,
match_presence_out boolean NOT NULL
);
CREATE TABLE private_storage (
username text NOT NULL,
server_host text NOT NULL,
namespace text NOT NULL,
data text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (server_host, username, namespace)
);
CREATE INDEX i_private_storage_sh_username ON private_storage (server_host, username);
CREATE TABLE roster_version (
username text NOT NULL,
server_host text NOT NULL,
version text NOT NULL,
PRIMARY KEY (server_host, username)
);
CREATE TABLE pubsub_node (
host text NOT NULL,
node text NOT NULL,
parent text NOT NULL DEFAULT '',
plugin text NOT NULL,
nodeid INTEGER PRIMARY KEY AUTOINCREMENT
);
CREATE INDEX i_pubsub_node_parent ON pubsub_node (parent);
CREATE UNIQUE INDEX i_pubsub_node_tuple ON pubsub_node (host, node);
CREATE TABLE pubsub_node_option (
nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE,
name text NOT NULL,
val text NOT NULL
);
CREATE INDEX i_pubsub_node_option_nodeid ON pubsub_node_option (nodeid);
CREATE TABLE pubsub_node_owner (
nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE,
owner text NOT NULL
);
CREATE INDEX i_pubsub_node_owner_nodeid ON pubsub_node_owner (nodeid);
CREATE TABLE pubsub_state (
nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE,
jid text NOT NULL,
affiliation character(1),
subscriptions text NOT NULL DEFAULT '',
stateid INTEGER PRIMARY KEY AUTOINCREMENT
);
CREATE INDEX i_pubsub_state_jid ON pubsub_state (jid);
CREATE UNIQUE INDEX i_pubsub_state_tuple ON pubsub_state (nodeid, jid);
CREATE TABLE pubsub_item (
nodeid bigint REFERENCES pubsub_node(nodeid) ON DELETE CASCADE,
itemid text NOT NULL,
publisher text NOT NULL,
creation text NOT NULL,
modification text NOT NULL,
payload text NOT NULL DEFAULT ''
);
CREATE INDEX i_pubsub_item_itemid ON pubsub_item (itemid);
CREATE UNIQUE INDEX i_pubsub_item_tuple ON pubsub_item (nodeid, itemid);
CREATE TABLE pubsub_subscription_opt (
subid text NOT NULL,
opt_name varchar(32),
opt_value text NOT NULL
);
CREATE UNIQUE INDEX i_pubsub_subscription_opt ON pubsub_subscription_opt (subid, opt_name);
CREATE TABLE muc_room (
name text NOT NULL,
server_host text NOT NULL,
host text NOT NULL,
opts text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE UNIQUE INDEX i_muc_room_name_host ON muc_room (name, host);
CREATE TABLE muc_registered (
jid text NOT NULL,
host text NOT NULL,
server_host text NOT NULL,
nick text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX i_muc_registered_nick ON muc_registered (nick);
CREATE UNIQUE INDEX i_muc_registered_jid_host ON muc_registered (jid, host);
CREATE TABLE muc_online_room (
name text NOT NULL,
host text NOT NULL,
server_host text NOT NULL,
node text NOT NULL,
pid text NOT NULL
);
CREATE UNIQUE INDEX i_muc_online_room_name_host ON muc_online_room (name, host);
CREATE TABLE muc_online_users (
username text NOT NULL,
server text NOT NULL,
resource text NOT NULL,
name text NOT NULL,
host text NOT NULL,
server_host text NOT NULL,
node text NOT NULL
);
CREATE UNIQUE INDEX i_muc_online_users ON muc_online_users (username, server, resource, name, host);
CREATE INDEX i_muc_online_users_us ON muc_online_users (username, server);
CREATE TABLE muc_room_subscribers (
room text NOT NULL,
host text NOT NULL,
jid text NOT NULL,
nick text NOT NULL,
nodes text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX i_muc_room_subscribers_host_jid ON muc_room_subscribers(host, jid);
CREATE UNIQUE INDEX i_muc_room_subscribers_host_room_jid ON muc_room_subscribers(host, room, jid);
CREATE TABLE irc_custom (
jid text NOT NULL,
host text NOT NULL,
server_host text NOT NULL,
data text NOT NULL,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE UNIQUE INDEX i_irc_custom_jid_host ON irc_custom (jid, host);
CREATE TABLE motd (
username text NOT NULL,
server_host text NOT NULL,
xml text,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (server_host, username)
);
CREATE TABLE caps_features (
node text NOT NULL,
subnode text NOT NULL,
feature text,
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX i_caps_features_node_subnode ON caps_features (node, subnode);
CREATE TABLE sm (
usec bigint NOT NULL,
pid text NOT NULL,
node text NOT NULL,
username text NOT NULL,
server_host text NOT NULL,
resource text NOT NULL,
priority text NOT NULL,
info text NOT NULL,
PRIMARY KEY (usec, pid)
);
CREATE INDEX i_sm_node ON sm(node);
CREATE INDEX i_sm_sh_username ON sm (server_host, username);
CREATE TABLE oauth_token (
token text NOT NULL PRIMARY KEY,
jid text NOT NULL,
scope text NOT NULL,
expire bigint NOT NULL
);
CREATE TABLE route (
domain text NOT NULL,
server_host text NOT NULL,
node text NOT NULL,
pid text NOT NULL,
local_hint text NOT NULL
);
CREATE UNIQUE INDEX i_route ON route(domain, server_host, node, pid);
CREATE INDEX i_route_domain ON route(domain);
CREATE TABLE bosh (
sid text NOT NULL,
node text NOT NULL,
pid text NOT NULL
);
CREATE UNIQUE INDEX i_bosh_sid ON bosh(sid);
CREATE TABLE carboncopy (
username text NOT NULL,
server_host text NOT NULL,
resource text NOT NULL,
namespace text NOT NULL,
node text NOT NULL,
PRIMARY KEY (server_host, username, resource)
);
CREATE INDEX i_carboncopy_sh_user ON carboncopy (server_host, username);
CREATE TABLE proxy65 (
sid text NOT NULL,
pid_t text NOT NULL,
pid_i text NOT NULL,
node_t text NOT NULL,
node_i text NOT NULL,
jid_i text NOT NULL
);
CREATE UNIQUE INDEX i_proxy65_sid ON proxy65 (sid);
CREATE INDEX i_proxy65_jid ON proxy65 (jid_i);
CREATE TABLE push_session (
username text NOT NULL,
server_host text NOT NULL,
timestamp bigint NOT NULL,
service text NOT NULL,
node text NOT NULL,
xml text NOT NULL,
PRIMARY KEY (server_host, username, timestamp)
);
CREATE UNIQUE INDEX i_push_session_susn ON push_session (server_host, username, service, node);
ejabberd-18.01/configure.ac 0000644 0002322 0002322 00000024006 13225667421 016127 0 ustar debalance debalance # -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.53)
AC_INIT(ejabberd, 18.01, ejabberd@process-one.net, ejabberd)
REQUIRE_ERLANG_MIN="6.4 (Erlang/OTP 17.5)"
REQUIRE_ERLANG_MAX="100.0.0 (No Max)"
AC_CONFIG_MACRO_DIR([m4])
# Checks for programs.
AC_PROG_MAKE_SET
AC_PROG_INSTALL
AC_PROG_SED
if test "x$GCC" = "xyes"; then
CFLAGS="$CFLAGS -Wall"
fi
# Checks Erlang runtime and compiler
AC_ARG_WITH(erlang,
AC_HELP_STRING([--with-erlang=dir],
[search for erlang in dir]),
[if test "$withval" = "yes" -o "$withval" = "no" -o "X$with_erlang" = "X"; then
extra_erl_path=""
else
extra_erl_path="$with_erlang:$with_erlang/bin:"
fi
])
AC_PATH_TOOL(ERL, erl, , [${extra_erl_path}$PATH])
AC_PATH_TOOL(ERLC, erlc, , [${extra_erl_path}$PATH])
AC_PATH_TOOL(EPMD, epmd, , [${extra_erl_path}$PATH])
AC_ERLANG_NEED_ERL
AC_ERLANG_NEED_ERLC
AC_ARG_ENABLE(erlang-version-check,
[AC_HELP_STRING([--enable-erlang-version-check],
[Check Erlang/OTP version @<:@default=yes@:>@])])
case "$enable_erlang_version_check" in
yes|'')
ERLANG_VERSION_CHECK([$REQUIRE_ERLANG_MIN],[$REQUIRE_ERLANG_MAX])
;;
no)
ERLANG_VERSION_CHECK([$REQUIRE_ERLANG_MIN],[$REQUIRE_ERLANG_MAX],[warn])
;;
esac
# Checks and sets ERLANG_ROOT_DIR and ERLANG_LIB_DIR variable
AC_ERLANG_SUBST_ROOT_DIR
# AC_ERLANG_SUBST_LIB_DIR
#locating escript
AC_PATH_PROG([ESCRIPT], [escript], [], [$ERLANG_ROOT_DIR/bin])
#locating make
AC_CHECK_PROG([MAKE], [make], [make], [])
if test "x$ESCRIPT" = "x"; then
AC_MSG_ERROR(['escript' was not found])
fi
if test "x$MAKE" = "x"; then
AC_MSG_ERROR(['make' was not found])
fi
# Change default prefix
AC_PREFIX_DEFAULT(/usr/local)
AC_ARG_ENABLE(hipe,
[AC_HELP_STRING([--enable-hipe], [compile natively with HiPE, not recommended (default: no)])],
[case "${enableval}" in
yes) hipe=true ;;
no) hipe=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-hipe) ;;
esac],[hipe=false])
AC_ARG_ENABLE(roster_gateway_workaround,
[AC_HELP_STRING([--enable-roster-gateway-workaround], [turn on workaround for processing gateway subscriptions (default: no)])],
[case "${enableval}" in
yes) roster_gateway_workaround=true ;;
no) roster_gateway_workaround=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-roster-gateway-workaround) ;;
esac],[roster_gateway_workaround=false])
AC_ARG_ENABLE(new_sql_schema,
[AC_HELP_STRING([--enable-new-sql-schema], [use new SQL schema (default: no)])],
[case "${enableval}" in
yes) new_sql_schema=true ;;
no) new_sql_schema=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-new-sql-schema) ;;
esac],[new_sql_schema=false])
AC_ARG_ENABLE(full_xml,
[AC_HELP_STRING([--enable-full-xml], [use XML features in XMPP stream (ex: CDATA) (default: no, requires XML compliant clients)])],
[case "${enableval}" in
yes) full_xml=true ;;
no) full_xml=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-full-xml) ;;
esac],[full_xml=false])
AC_ARG_ENABLE(mssql,
[AC_HELP_STRING([--enable-mssql], [use Microsoft SQL Server database (default: no, requires --enable-odbc)])],
[case "${enableval}" in
yes) db_type=mssql ;;
no) db_type=generic ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-mssql) ;;
esac],[db_type=generic])
AC_ARG_ENABLE(all,
[AC_HELP_STRING([--enable-all], [same as --enable-odbc --enable-mysql --enable-pgsql --enable-sqlite --enable-pam --enable-zlib --enable-riak --enable-redis --enable-elixir --enable-iconv --enable-stun --enable-sip --enable-debug --enable-tools (useful for Dialyzer checks, default: no)])],
[case "${enableval}" in
yes) odbc=true mysql=true pgsql=true sqlite=true pam=true zlib=true riak=true redis=true elixir=true iconv=true stun=true sip=true debug=true tools=true ;;
no) odbc=false mysql=false pgsql=false sqlite=false pam=false zlib=false riak=false redis=false elixir=false iconv=false stun=false sip=false debug=false tools=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-all) ;;
esac],[])
AC_ARG_ENABLE(tools,
[AC_HELP_STRING([--enable-tools], [build development tools (default: no)])],
[case "${enableval}" in
yes) tools=true ;;
no) tools=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-tools) ;;
esac],[if test "x$tools" = "x"; then tools=false; fi])
AC_ARG_ENABLE(odbc,
[AC_HELP_STRING([--enable-odbc], [enable pure ODBC support (default: no)])],
[case "${enableval}" in
yes) odbc=true ;;
no) odbc=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-odbc) ;;
esac],[if test "x$odbc" = "x"; then odbc=false; fi])
AC_ARG_ENABLE(mysql,
[AC_HELP_STRING([--enable-mysql], [enable MySQL support (default: no)])],
[case "${enableval}" in
yes) mysql=true ;;
no) mysql=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-mysql) ;;
esac],[if test "x$mysql" = "x"; then mysql=false; fi])
AC_ARG_ENABLE(pgsql,
[AC_HELP_STRING([--enable-pgsql], [enable PostgreSQL support (default: no)])],
[case "${enableval}" in
yes) pgsql=true ;;
no) pgsql=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-pgsql) ;;
esac],[if test "x$pgsql" = "x"; then pgsql=false; fi])
AC_ARG_ENABLE(sqlite,
[AC_HELP_STRING([--enable-sqlite], [enable SQLite support (default: no)])],
[case "${enableval}" in
yes) sqlite=true ;;
no) sqlite=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-sqlite) ;;
esac],[if test "x$sqlite" = "x"; then sqlite=false; fi])
AC_ARG_ENABLE(pam,
[AC_HELP_STRING([--enable-pam], [enable PAM support (default: no)])],
[case "${enableval}" in
yes) pam=true ;;
no) pam=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-pam) ;;
esac],[if test "x$pam" = "x"; then pam=false; fi])
AC_ARG_ENABLE(zlib,
[AC_HELP_STRING([--enable-zlib], [enable Stream Compression (XEP-0138) using zlib (default: yes)])],
[case "${enableval}" in
yes) zlib=true ;;
no) zlib=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-zlib) ;;
esac],[if test "x$zlib" = "x"; then zlib=true; fi])
AC_ARG_ENABLE(riak,
[AC_HELP_STRING([--enable-riak], [enable Riak support (default: no)])],
[case "${enableval}" in
yes) riak=true ;;
no) riak=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-riak) ;;
esac],[if test "x$riak" = "x"; then riak=false; fi])
AC_ARG_ENABLE(redis,
[AC_HELP_STRING([--enable-redis], [enable Redis support (default: no)])],
[case "${enableval}" in
yes) redis=true ;;
no) redis=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-redis) ;;
esac],[if test "x$redis" = "x"; then redis=false; fi])
AC_ARG_ENABLE(elixir,
[AC_HELP_STRING([--enable-elixir], [enable Elixir support (default: no)])],
[case "${enableval}" in
yes) elixir=true ;;
no) elixir=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-elixir) ;;
esac],[if test "x$elixir" = "x"; then elixir=false; fi])
AC_ARG_ENABLE(iconv,
[AC_HELP_STRING([--enable-iconv], [enable iconv support (default: yes)])],
[case "${enableval}" in
yes) iconv=true ;;
no) iconv=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-iconv) ;;
esac],[if test "x$iconv" = "x"; then iconv=true; fi])
AC_ARG_ENABLE(debug,
[AC_HELP_STRING([--enable-debug], [enable debug information (default: yes)])],
[case "${enableval}" in
yes) debug=true ;;
no) debug=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-debug) ;;
esac],[if test "x$debug" = "x"; then debug=true; fi])
AC_ARG_ENABLE(latest_deps,
[AC_HELP_STRING([--enable-latest-deps], [makes rebar use latest commits for dependences instead of tagged versions (default: no)])],
[case "${enableval}" in
yes) latest_deps=true ;;
no) latest_deps=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-latest-deps) ;;
esac],[if test "x$latest_deps" = "x"; then latest_deps=false; fi])
AC_ARG_ENABLE(system_deps,
[AC_HELP_STRING([--enable-system-deps], [makes rebar use localy installed dependences instead of downloading them (default: no)])],
[case "${enableval}" in
yes) system_deps=true ;;
no) system_deps=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-system-deps) ;;
esac],[if test "x$system_deps" = "x"; then system_deps=false; fi])
AC_ARG_ENABLE(stun,
[AC_HELP_STRING([--enable-stun], [enable STUN/TURN support (default: no)])],
[case "${enableval}" in
yes) stun=true ;;
no) stun=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-stun) ;;
esac],[if test "x$stun" = "x"; then stun=false; fi])
AC_ARG_ENABLE(sip,
[AC_HELP_STRING([--enable-sip], [enable SIP support (default: no)])],
[case "${enableval}" in
yes) sip=true ;;
no) sip=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-sip) ;;
esac],[if test "x$sip" = "x"; then sip=false; fi])
AC_ARG_ENABLE(graphics,
[AC_HELP_STRING([--enable-graphics], [enable support for graphic images manipulation (default: yes)])],
[case "${enableval}" in
yes) graphics=true ;;
no) graphics=false ;;
*) AC_MSG_ERROR(bad value ${enableval} for --enable-graphics) ;;
esac],[if test "x$graphics" = "x"; then graphics=true; fi])
AC_CONFIG_FILES([Makefile
vars.config
src/ejabberd.app.src])
ENABLEUSER=""
AC_ARG_ENABLE(user,
[AS_HELP_STRING([--enable-user[[[[=USER]]]]], [allow this system user to start ejabberd (default: no)])],
[case "${enableval}" in
yes) ENABLEUSER=`whoami` ;;
no) ENABLEUSER="" ;;
*) ENABLEUSER=$enableval
esac],
[])
if test "$ENABLEUSER" != ""; then
echo "allow this system user to start ejabberd: $ENABLEUSER"
AC_SUBST([INSTALLUSER], [$ENABLEUSER])
fi
ERLANG_DEPRECATED_TYPES_CHECK
if test "$sqlite" = "true"; then
AX_LIB_SQLITE3([3.6.19])
if test "x$SQLITE3_VERSION" = "x"; then
AC_MSG_ERROR(SQLite3 library >= 3.6.19 was not found)
fi
fi
AC_SUBST(hipe)
AC_SUBST(roster_gateway_workaround)
AC_SUBST(new_sql_schema)
AC_SUBST(full_xml)
AC_SUBST(db_type)
AC_SUBST(odbc)
AC_SUBST(mysql)
AC_SUBST(pgsql)
AC_SUBST(sqlite)
AC_SUBST(pam)
AC_SUBST(zlib)
AC_SUBST(riak)
AC_SUBST(redis)
AC_SUBST(elixir)
AC_SUBST(iconv)
AC_SUBST(stun)
AC_SUBST(sip)
AC_SUBST(debug)
AC_SUBST(graphics)
AC_SUBST(tools)
AC_SUBST(latest_deps)
AC_SUBST(system_deps)
AC_SUBST(CFLAGS)
AC_SUBST(CPPFLAGS)
AC_SUBST(LDFLAGS)
AC_OUTPUT
ejabberd-18.01/autogen.sh 0000755 0002322 0002322 00000000064 13225664356 015644 0 ustar debalance debalance # generate a new autoconf
aclocal -I m4
autoconf -f
ejabberd-18.01/priv/ 0000755 0002322 0002322 00000000000 13225664356 014623 5 ustar debalance debalance ejabberd-18.01/priv/img/ 0000755 0002322 0002322 00000000000 13225664356 015377 5 ustar debalance debalance ejabberd-18.01/priv/img/valid-xhtml10.png 0000644 0002322 0002322 00000004556 13225664356 020511 0 ustar debalance debalance PNG
IHDR X #D PLTE {9ތBBcZZބB{{ޥ{RssޭRZs{Rc19Jc 猭RZ)J!{{{ZZJs9JZRJsssJ k1! c1kkkBs9ƜJccck1c1kcRk99J֜ kk ƥZε9999R){9{c1s9111J! 1{J k1 ){)))ZֵBƽZ9))csZΥZkcRcR)cJ) 9c 1{9Zs1Z{skZB{BJJsBsBBJJkB9skR)!sZ1kB1scRkZRB!ΥRkR)ZcsRcZZZZ9BJZ)ZJRRR!Z J1kk) BJ{JJJ{ֵccZR֭cBBBޭc91cZ{sR1){J9{kR1!{ZJ!֭R)!sZ)ZZB!c֥R{RcckR!sZsZRJ!9sJRRJ9kRJJ!Rc B? tRNSlIty] Dq>` IDATxڕV_E˻aFڊQY DTrDiPP"|94B":$4G):[F~3w~=fs@Ŵ{"Ք5CYeF$WPVFt'1|NcDc>1YÕ-{~BI`[%[v[#I$H%aD|D cO(Loau()y*aҺ)}*`&lf0wvӿfXmM>Dزn9kZ2ps!acf&Ia:Tqsr=4On
XL|Ԥjar|c9G+@yuJ\#1twA#G4H_5A=xb9*t5o{x5I,M*: AN (Y$Im9Hbmi feNBK~nfk~[pcD16)@hi)M?R&ȅHY)m4ZdTt#4~"T%.eVv%_ȥXd^.ЪhlzfRJdds*tYF\8LhX:֝U"_7e[ʆigJ;ܽqg7:AQOzr`7PaaaL፞g4@> n;4h[l``'N
!Ҩ ύWO