Annotate

plugins/mod_storage_internal.lua @ 5087:71a5a6a6c74c

portmanager: Support 'local_interfaces' config option (default for private listeners like components, telnet, etc.) (thanks mva)
author Matthew Wild <mwild1@gmail.com>
date Fri, 10 Aug 2012 16:31:51 +0100
parent 5039:656ce68c4781
child 5121:b5a5643f8572
child 5130:051d352ed03c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4085
7699cef04740 storagemanager, mod_storage_internal: Split out default driver to mod_storage_internal, and greatly simplify storagemanager's error handling and fallback code
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
1 local datamanager = require "core.storagemanager".olddm;
7699cef04740 storagemanager, mod_storage_internal: Split out default driver to mod_storage_internal, and greatly simplify storagemanager's error handling and fallback code
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
2
7699cef04740 storagemanager, mod_storage_internal: Split out default driver to mod_storage_internal, and greatly simplify storagemanager's error handling and fallback code
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
3 local host = module.host;
7699cef04740 storagemanager, mod_storage_internal: Split out default driver to mod_storage_internal, and greatly simplify storagemanager's error handling and fallback code
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
4
7699cef04740 storagemanager, mod_storage_internal: Split out default driver to mod_storage_internal, and greatly simplify storagemanager's error handling and fallback code
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
5 local driver = { name = "internal" };
7699cef04740 storagemanager, mod_storage_internal: Split out default driver to mod_storage_internal, and greatly simplify storagemanager's error handling and fallback code
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
6 local driver_mt = { __index = driver };
7699cef04740 storagemanager, mod_storage_internal: Split out default driver to mod_storage_internal, and greatly simplify storagemanager's error handling and fallback code
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
7
7699cef04740 storagemanager, mod_storage_internal: Split out default driver to mod_storage_internal, and greatly simplify storagemanager's error handling and fallback code
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
8 function driver:open(store)
7699cef04740 storagemanager, mod_storage_internal: Split out default driver to mod_storage_internal, and greatly simplify storagemanager's error handling and fallback code
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
9 return setmetatable({ store = store }, driver_mt);
7699cef04740 storagemanager, mod_storage_internal: Split out default driver to mod_storage_internal, and greatly simplify storagemanager's error handling and fallback code
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
10 end
7699cef04740 storagemanager, mod_storage_internal: Split out default driver to mod_storage_internal, and greatly simplify storagemanager's error handling and fallback code
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
11 function driver:get(user)
7699cef04740 storagemanager, mod_storage_internal: Split out default driver to mod_storage_internal, and greatly simplify storagemanager's error handling and fallback code
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
12 return datamanager.load(user, host, self.store);
7699cef04740 storagemanager, mod_storage_internal: Split out default driver to mod_storage_internal, and greatly simplify storagemanager's error handling and fallback code
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
13 end
7699cef04740 storagemanager, mod_storage_internal: Split out default driver to mod_storage_internal, and greatly simplify storagemanager's error handling and fallback code
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
14
7699cef04740 storagemanager, mod_storage_internal: Split out default driver to mod_storage_internal, and greatly simplify storagemanager's error handling and fallback code
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
15 function driver:set(user, data)
7699cef04740 storagemanager, mod_storage_internal: Split out default driver to mod_storage_internal, and greatly simplify storagemanager's error handling and fallback code
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
16 return datamanager.store(user, host, self.store, data);
7699cef04740 storagemanager, mod_storage_internal: Split out default driver to mod_storage_internal, and greatly simplify storagemanager's error handling and fallback code
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
17 end
7699cef04740 storagemanager, mod_storage_internal: Split out default driver to mod_storage_internal, and greatly simplify storagemanager's error handling and fallback code
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
18
5033
c64b5081bfa8 mod_storage_internal: Add method for listing stores
Kim Alvefur <zash@zash.se>
parents: 4085
diff changeset
19 function driver:list_stores(username)
c64b5081bfa8 mod_storage_internal: Add method for listing stores
Kim Alvefur <zash@zash.se>
parents: 4085
diff changeset
20 return datamanager.list_stores(username, host);
c64b5081bfa8 mod_storage_internal: Add method for listing stores
Kim Alvefur <zash@zash.se>
parents: 4085
diff changeset
21 end
c64b5081bfa8 mod_storage_internal: Add method for listing stores
Kim Alvefur <zash@zash.se>
parents: 4085
diff changeset
22
5039
656ce68c4781 mod_storage_internal: Add method for removing all data belonging to a user
Kim Alvefur <zash@zash.se>
parents: 5033
diff changeset
23 function driver:purge(user)
656ce68c4781 mod_storage_internal: Add method for removing all data belonging to a user
Kim Alvefur <zash@zash.se>
parents: 5033
diff changeset
24 return datamanager.purge(user, host);
656ce68c4781 mod_storage_internal: Add method for removing all data belonging to a user
Kim Alvefur <zash@zash.se>
parents: 5033
diff changeset
25 end
656ce68c4781 mod_storage_internal: Add method for removing all data belonging to a user
Kim Alvefur <zash@zash.se>
parents: 5033
diff changeset
26
4085
7699cef04740 storagemanager, mod_storage_internal: Split out default driver to mod_storage_internal, and greatly simplify storagemanager's error handling and fallback code
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
27 module:add_item("data-driver", driver);