mirror of
https://github.com/falk-werner/webfuse-provider
synced 2026-03-02 04:09:18 +00:00
renamed to webfuse
This commit is contained in:
@@ -9,25 +9,25 @@
|
||||
#include <getopt.h>
|
||||
#include <jansson.h>
|
||||
|
||||
#include <wsfs_adapter.h>
|
||||
#include <webfuse_adapter.h>
|
||||
|
||||
|
||||
struct args
|
||||
{
|
||||
struct wsfs_server_config * config;
|
||||
struct wf_server_config * config;
|
||||
char * passwd_path;
|
||||
bool show_help;
|
||||
};
|
||||
|
||||
static struct wsfs_server * server;
|
||||
static struct wf_server * server;
|
||||
|
||||
static void show_help(void)
|
||||
{
|
||||
printf(
|
||||
"wsfsd, Copyright (c) 2019, Falk Werner\n"
|
||||
"webfused, Copyright (c) 2019, webfuse authors <https://github.com/falk-werner/webfuse>\n"
|
||||
"Websocket file system daemon\n"
|
||||
"\n"
|
||||
"Usage: wsfsd [m <mount_point>] [-d <document_root] [-n <vhost_name>] [-p <port>]\n"
|
||||
"Usage: webfused [m <mount_point>] [-d <document_root] [-n <vhost_name>] [-p <port>]\n"
|
||||
" [-c <server_cert_path>] [-k <server_key_path>] [-P <passwd_path>]\n"
|
||||
"\n"
|
||||
"Options:\n"
|
||||
@@ -41,13 +41,13 @@ static void show_help(void)
|
||||
"\n");
|
||||
}
|
||||
|
||||
static bool authenticate(struct wsfs_credentials * creds, void * user_data)
|
||||
static bool authenticate(struct wf_credentials * creds, void * user_data)
|
||||
{
|
||||
bool result = false;
|
||||
struct args * args = user_data;
|
||||
|
||||
char const * username = wsfs_credentials_get(creds, "username");
|
||||
char const * password = wsfs_credentials_get(creds, "password");
|
||||
char const * username = wf_credentials_get(creds, "username");
|
||||
char const * password = wf_credentials_get(creds, "password");
|
||||
if ((NULL != username) && (NULL != password))
|
||||
{
|
||||
json_t * passwd = json_load_file(args->passwd_path, 0, NULL);
|
||||
@@ -103,28 +103,28 @@ static int parse_arguments(int argc, char * argv[], struct args * args)
|
||||
finished = true;
|
||||
break;
|
||||
case 'm':
|
||||
wsfs_server_config_set_mountpoint(args->config, optarg);
|
||||
wf_server_config_set_mountpoint(args->config, optarg);
|
||||
has_mountpoint = true;
|
||||
break;
|
||||
case 'd':
|
||||
wsfs_server_config_set_documentroot(args->config, optarg);
|
||||
wf_server_config_set_documentroot(args->config, optarg);
|
||||
break;
|
||||
case 'c':
|
||||
wsfs_server_config_set_certpath(args->config, optarg);
|
||||
wf_server_config_set_certpath(args->config, optarg);
|
||||
break;
|
||||
case 'k':
|
||||
wsfs_server_config_set_keypath(args->config, optarg);
|
||||
wf_server_config_set_keypath(args->config, optarg);
|
||||
break;
|
||||
case 'n':
|
||||
wsfs_server_config_set_vhostname(args->config, optarg);
|
||||
wf_server_config_set_vhostname(args->config, optarg);
|
||||
break;
|
||||
case 'p':
|
||||
wsfs_server_config_set_port(args->config, atoi(optarg));
|
||||
wf_server_config_set_port(args->config, atoi(optarg));
|
||||
break;
|
||||
case 'P':
|
||||
free(args->passwd_path);
|
||||
args->passwd_path = strdup(optarg);
|
||||
wsfs_server_config_add_authenticator(args->config,
|
||||
wf_server_config_add_authenticator(args->config,
|
||||
"username",
|
||||
&authenticate,
|
||||
args);
|
||||
@@ -157,15 +157,15 @@ static void on_interrupt(int signal_id)
|
||||
{
|
||||
(void) signal_id;
|
||||
|
||||
wsfs_server_shutdown(server);
|
||||
wf_server_shutdown(server);
|
||||
}
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
struct args args;
|
||||
args.config = wsfs_server_config_create();
|
||||
wsfs_server_config_set_vhostname(args.config, "localhost");
|
||||
wsfs_server_config_set_port(args.config, 8080);
|
||||
args.config = wf_server_config_create();
|
||||
wf_server_config_set_vhostname(args.config, "localhost");
|
||||
wf_server_config_set_port(args.config, 8080);
|
||||
args.passwd_path = NULL;
|
||||
args.show_help = false;
|
||||
|
||||
@@ -174,11 +174,11 @@ int main(int argc, char * argv[])
|
||||
if (!args.show_help)
|
||||
{
|
||||
signal(SIGINT, on_interrupt);
|
||||
server = wsfs_server_create(args.config);
|
||||
server = wf_server_create(args.config);
|
||||
if (NULL != server)
|
||||
{
|
||||
wsfs_server_run(server);
|
||||
wsfs_server_dispose(server);
|
||||
wf_server_run(server);
|
||||
wf_server_dispose(server);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -192,7 +192,7 @@ int main(int argc, char * argv[])
|
||||
}
|
||||
|
||||
free(args.passwd_path);
|
||||
wsfs_server_config_dispose(args.config);
|
||||
wf_server_config_dispose(args.config);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
/* eslint no-unused-vars: ["error", { "argsIgnorePattern": "^_" }] */
|
||||
|
||||
import { BadState } from "./wsfs/bad_state.js";
|
||||
import { FileMode } from "./wsfs/file_mode.js";
|
||||
import { Provider } from "./wsfs/provider.js";
|
||||
import { BadState } from "./webfuse/bad_state.js";
|
||||
import { FileMode } from "./webfuse/file_mode.js";
|
||||
import { Provider } from "./webfuse/provider.js";
|
||||
|
||||
export class FileSystemProvider extends Provider {
|
||||
constructor(root) {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "wsfs-provider",
|
||||
"name": "webfuse-provider",
|
||||
"version": "0.1.0",
|
||||
"description": "Provider for websocket filesystem (wsfs)",
|
||||
"description": "Provider for websocket filesystem (webfuse)",
|
||||
"main": "startup.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Client } from "./wsfs/client.js";
|
||||
import { Client } from "./webfuse/client.js";
|
||||
import { ConnectionView } from "./connection_view.js";
|
||||
import { FileSystemProvider } from "./filesystem_provider.js";
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ static bool is_compatible(json_t * meta)
|
||||
|
||||
result = (
|
||||
json_is_string(type) &&
|
||||
(0 == strcmp(json_string_value(type), "wsfs-userdb")) &&
|
||||
(0 == strcmp(json_string_value(type), "wf-userdb")) &&
|
||||
json_is_integer(major) &&
|
||||
(USERDB_MAJOR == json_integer_value(major)) &&
|
||||
json_is_integer(minor) &&
|
||||
@@ -170,7 +170,7 @@ bool userdb_save(
|
||||
json_t * container = json_object();
|
||||
|
||||
json_t * meta = json_object();
|
||||
json_object_set_new(meta, "type", json_string("wsfs-userdb"));
|
||||
json_object_set_new(meta, "type", json_string("wf-userdb"));
|
||||
json_object_set_new(meta, "major", json_integer(USERDB_MAJOR));
|
||||
json_object_set_new(meta, "minor", json_integer(USERDB_MINOR));
|
||||
json_object_set_new(meta, "hash_algorithm", json_string(db->hash_algorithm));
|
||||
|
||||
@@ -36,13 +36,13 @@ struct command
|
||||
static void print_usage(void)
|
||||
{
|
||||
printf(
|
||||
"wsfs-passwd, Copyright (c) 2019 authors <https://github.com/falk-werner/fuse-wsfs>\n"
|
||||
"Manage wsfs passwd file\n"
|
||||
"webfuse-passwd, Copyright (c) 2019, webfuse authors <https://github.com/falk-werner/webfuse>\n"
|
||||
"Manage webfuse passwd file\n"
|
||||
"\n"
|
||||
"Usage: wsfs-passwd -f <file> -c <command> [-u <username>] [-p <password>] [-P <pepper>]\n"
|
||||
"Usage: webfuse-passwd -f <file> -c <command> [-u <username>] [-p <password>] [-P <pepper>]\n"
|
||||
"\n"
|
||||
"Options:\n"
|
||||
"\t-f, --file Path of wsfs passwd file\n"
|
||||
"\t-f, --file Path of wf passwd file\n"
|
||||
"\t-c, --command Command to execute\n"
|
||||
"\t-u, --username Name of user\n"
|
||||
"\t-p, --password Password of user\n"
|
||||
@@ -51,13 +51,13 @@ static void print_usage(void)
|
||||
"\n"
|
||||
"Commands:\n"
|
||||
"\tcreate Creates an empty passwd file (or cleans an existing)\n"
|
||||
"\t Example: wsfs-passwd -f passwd.json -c create\n"
|
||||
"\t Example: webfuse-passwd -f passwd.json -c create\n"
|
||||
"\tadd Adds or replaces a user\n"
|
||||
"\t Example: wsfs-passwd -f passwd.json -c add -u bob -p secret\n"
|
||||
"\t Example: webfuse-passwd -f passwd.json -c add -u bob -p secret\n"
|
||||
"\tremove Removes a user\n"
|
||||
"\t Example: wsfs-passwd -f passwd.json -c remove -u bob\n"
|
||||
"\t Example: webfuse-passwd -f passwd.json -c remove -u bob\n"
|
||||
"\tcheck Checks password of a user\n"
|
||||
"\t Example: wsfs-passwd -f passwd.json -c check -u bob -p secret\n"
|
||||
"\t Example: webfuse-passwd -f passwd.json -c check -u bob -p secret\n"
|
||||
"\n"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -9,12 +9,12 @@
|
||||
#include <unistd.h>
|
||||
#include <getopt.h>
|
||||
|
||||
#include "wsfs_provider.h"
|
||||
#include "webfuse_provider.h"
|
||||
|
||||
struct config
|
||||
{
|
||||
char * url;
|
||||
struct wsfsp_client_config * client_config;
|
||||
struct wfp_client_config * client_config;
|
||||
bool show_help;
|
||||
};
|
||||
|
||||
@@ -43,19 +43,19 @@ struct fs
|
||||
static void show_help()
|
||||
{
|
||||
printf(
|
||||
"wsfs-provider, Copyright (c) 2019 fuse-wsfs authors <https://github.com/falk-werner/fuse-wsfs>\n"
|
||||
"webfuse-provider, Copyright (c) 2019, webfuse authors <https://github.com/falk-werner/webfuse>\n"
|
||||
"Example for websocket file system provider\n"
|
||||
"\n"
|
||||
"Usage: wsfs-provider -u <url> [-k <key_path>] [-c <cert_path>]\n"
|
||||
"Usage: webfuse-provider -u <url> [-k <key_path>] [-c <cert_path>]\n"
|
||||
"\n"
|
||||
"Options:\n"
|
||||
"\t-u, --url URL of WSFS server (required)\n"
|
||||
"\t-u, --url URL of webfuse server (required)\n"
|
||||
"\t-k, --key_path Path to private key of provider (default: not set, TLS disabled)\n"
|
||||
"\t-c, --cert_path Path to certificate of provider (defautl: not set, TLS disabled)\n"
|
||||
"\t-h, --help prints this message\n"
|
||||
"\n"
|
||||
"Example:\n"
|
||||
"\twsfs-provider -u ws://localhost:8080/\n"
|
||||
"\twebfuse-provider -u ws://localhost:8080/\n"
|
||||
"\n"
|
||||
);
|
||||
}
|
||||
@@ -95,10 +95,10 @@ static int parse_arguments(
|
||||
config->url = strdup(optarg);
|
||||
break;
|
||||
case 'k':
|
||||
wsfsp_client_config_set_keypath(config->client_config, optarg);
|
||||
wfp_client_config_set_keypath(config->client_config, optarg);
|
||||
break;
|
||||
case 'c':
|
||||
wsfsp_client_config_set_certpath(config->client_config, optarg);
|
||||
wfp_client_config_set_certpath(config->client_config, optarg);
|
||||
break;
|
||||
default:
|
||||
fprintf(stderr, "error: unknown argument\n");
|
||||
@@ -177,7 +177,7 @@ static void fs_stat(
|
||||
}
|
||||
|
||||
static void fs_lookup(
|
||||
struct wsfsp_request * request,
|
||||
struct wfp_request * request,
|
||||
ino_t parent,
|
||||
char const * name,
|
||||
void * user_data)
|
||||
@@ -189,17 +189,17 @@ static void fs_lookup(
|
||||
struct stat stat;
|
||||
fs_stat(entry, &stat);
|
||||
|
||||
wsfsp_respond_lookup(request, &stat);
|
||||
wfp_respond_lookup(request, &stat);
|
||||
}
|
||||
else
|
||||
{
|
||||
wsfsp_respond_error(request, WSFS_BAD_NOENTRY);
|
||||
wfp_respond_error(request, WF_BAD_NOENTRY);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void fs_getattr(
|
||||
struct wsfsp_request * request,
|
||||
struct wfp_request * request,
|
||||
ino_t inode,
|
||||
void * user_data)
|
||||
{
|
||||
@@ -211,16 +211,16 @@ static void fs_getattr(
|
||||
struct stat stat;
|
||||
fs_stat(entry, &stat);
|
||||
|
||||
wsfsp_respond_getattr(request, &stat);
|
||||
wfp_respond_getattr(request, &stat);
|
||||
}
|
||||
else
|
||||
{
|
||||
wsfsp_respond_error(request, WSFS_BAD_NOENTRY);
|
||||
wfp_respond_error(request, WF_BAD_NOENTRY);
|
||||
}
|
||||
}
|
||||
|
||||
static void fs_readdir(
|
||||
struct wsfsp_request * request,
|
||||
struct wfp_request * request,
|
||||
ino_t directory,
|
||||
void * user_data)
|
||||
{
|
||||
@@ -229,30 +229,30 @@ static void fs_readdir(
|
||||
struct fs_entry const * dir = fs_getentry(fs, directory);
|
||||
if ((NULL != dir) && (FS_DIR == dir->type))
|
||||
{
|
||||
struct wsfsp_dirbuffer * buffer = wsfsp_dirbuffer_create();
|
||||
wsfsp_dirbuffer_add(buffer, ".", dir->inode);
|
||||
wsfsp_dirbuffer_add(buffer, "..", dir->inode);
|
||||
struct wfp_dirbuffer * buffer = wfp_dirbuffer_create();
|
||||
wfp_dirbuffer_add(buffer, ".", dir->inode);
|
||||
wfp_dirbuffer_add(buffer, "..", dir->inode);
|
||||
|
||||
for(size_t i = 0; 0 != fs->entries[i].inode; i++)
|
||||
{
|
||||
struct fs_entry const * entry = &fs->entries[i];
|
||||
if (directory == entry->parent)
|
||||
{
|
||||
wsfsp_dirbuffer_add(buffer, entry->name, entry->inode);
|
||||
wfp_dirbuffer_add(buffer, entry->name, entry->inode);
|
||||
}
|
||||
}
|
||||
|
||||
wsfsp_respond_readdir(request, buffer);
|
||||
wsfsp_dirbuffer_dispose(buffer);
|
||||
wfp_respond_readdir(request, buffer);
|
||||
wfp_dirbuffer_dispose(buffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
wsfsp_respond_error(request, WSFS_BAD_NOENTRY);
|
||||
wfp_respond_error(request, WF_BAD_NOENTRY);
|
||||
}
|
||||
}
|
||||
|
||||
static void fs_open(
|
||||
struct wsfsp_request * request,
|
||||
struct wfp_request * request,
|
||||
ino_t inode,
|
||||
int flags,
|
||||
void * user_data)
|
||||
@@ -264,16 +264,16 @@ static void fs_open(
|
||||
{
|
||||
if (O_RDONLY == (flags & O_ACCMODE))
|
||||
{
|
||||
wsfsp_respond_open(request, 0U);
|
||||
wfp_respond_open(request, 0U);
|
||||
}
|
||||
else
|
||||
{
|
||||
wsfsp_respond_error(request, WSFS_BAD_NOACCESS);
|
||||
wfp_respond_error(request, WF_BAD_NOACCESS);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wsfsp_respond_error(request, WSFS_BAD_NOENTRY);
|
||||
wfp_respond_error(request, WF_BAD_NOENTRY);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -283,7 +283,7 @@ static size_t min(size_t const a, size_t const b)
|
||||
}
|
||||
|
||||
static void fs_read(
|
||||
struct wsfsp_request * request,
|
||||
struct wfp_request * request,
|
||||
ino_t inode,
|
||||
uint32_t handle,
|
||||
size_t offset,
|
||||
@@ -301,26 +301,26 @@ static void fs_read(
|
||||
size_t const remaining = entry->content_length - offset;
|
||||
size_t const count = min(remaining, length);
|
||||
|
||||
wsfsp_respond_read(request, &entry->content[offset], count);
|
||||
wfp_respond_read(request, &entry->content[offset], count);
|
||||
}
|
||||
else
|
||||
{
|
||||
wsfsp_respond_error(request, WSFS_BAD);
|
||||
wfp_respond_error(request, WF_BAD);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
wsfsp_respond_error(request, WSFS_BAD_NOENTRY);
|
||||
wfp_respond_error(request, WF_BAD_NOENTRY);
|
||||
}
|
||||
}
|
||||
|
||||
static struct wsfsp_client * client;
|
||||
static struct wfp_client * client;
|
||||
|
||||
static void on_interrupt(int signal_id)
|
||||
{
|
||||
(void) signal_id;
|
||||
|
||||
wsfsp_client_shutdown(client);
|
||||
wfp_client_shutdown(client);
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[])
|
||||
@@ -328,7 +328,7 @@ int main(int argc, char* argv[])
|
||||
struct config config;
|
||||
config.url = NULL;
|
||||
config.show_help = false;
|
||||
config.client_config = wsfsp_client_config_create();
|
||||
config.client_config = wfp_client_config_create();
|
||||
int result = parse_arguments(argc, argv, &config);
|
||||
|
||||
if (EXIT_SUCCESS == result)
|
||||
@@ -355,19 +355,19 @@ int main(int argc, char* argv[])
|
||||
|
||||
signal(SIGINT, &on_interrupt);
|
||||
|
||||
wsfsp_client_config_set_userdata(config.client_config, &fs);
|
||||
wsfsp_client_config_set_onlookup(config.client_config, &fs_lookup);
|
||||
wsfsp_client_config_set_ongetattr(config.client_config, &fs_getattr);
|
||||
wsfsp_client_config_set_onreaddir(config.client_config, &fs_readdir);
|
||||
wsfsp_client_config_set_onopen(config.client_config, &fs_open);
|
||||
wsfsp_client_config_set_onread(config.client_config, &fs_read);
|
||||
wfp_client_config_set_userdata(config.client_config, &fs);
|
||||
wfp_client_config_set_onlookup(config.client_config, &fs_lookup);
|
||||
wfp_client_config_set_ongetattr(config.client_config, &fs_getattr);
|
||||
wfp_client_config_set_onreaddir(config.client_config, &fs_readdir);
|
||||
wfp_client_config_set_onopen(config.client_config, &fs_open);
|
||||
wfp_client_config_set_onread(config.client_config, &fs_read);
|
||||
|
||||
client = wsfsp_client_create(config.client_config);
|
||||
wsfsp_client_connect(client, config.url);
|
||||
client = wfp_client_create(config.client_config);
|
||||
wfp_client_connect(client, config.url);
|
||||
|
||||
wsfsp_client_run(client);
|
||||
wfp_client_run(client);
|
||||
|
||||
wsfsp_client_dispose(client);
|
||||
wfp_client_dispose(client);
|
||||
}
|
||||
|
||||
if (config.show_help)
|
||||
@@ -376,6 +376,6 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
|
||||
free(config.url);
|
||||
wsfsp_client_config_dispose(config.client_config);
|
||||
wfp_client_config_dispose(config.client_config);
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user