From a0ad1f9b47e38ea43d7eda68093edfdc7260de2d Mon Sep 17 00:00:00 2001 From: shockrah Date: Mon, 2 Dec 2019 13:47:13 -0800 Subject: [PATCH 1/5] more deps for diesel setup in a bit --- server/Cargo.lock | 53 +++++++++++++++++++++++++++++++++++++++++++++++ server/Cargo.toml | 1 + 2 files changed, 54 insertions(+) diff --git a/server/Cargo.lock b/server/Cargo.lock index 14df283..6b7b7fe 100644 --- a/server/Cargo.lock +++ b/server/Cargo.lock @@ -1,5 +1,13 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +[[package]] +name = "aho-corasick" +version = "0.6.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "aho-corasick" version = "0.7.6" @@ -118,6 +126,7 @@ name = "client" version = "0.1.0" dependencies = [ "diesel 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)", + "dotenv 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "rocket 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "rocket_contrib 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)", "serde 1.0.103 (registry+https://github.com/rust-lang/crates.io-index)", @@ -208,6 +217,14 @@ dependencies = [ "generic-array 0.12.3 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "dotenv" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "error-chain" version = "0.12.1" @@ -694,6 +711,18 @@ name = "redox_syscall" version = "0.1.56" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "regex" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "aho-corasick 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)", + "memchr 2.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", + "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "utf8-ranges 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "regex" version = "1.3.1" @@ -705,6 +734,14 @@ dependencies = [ "thread_local 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "regex-syntax" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ucd-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "regex-syntax" version = "0.6.12" @@ -987,6 +1024,11 @@ name = "ucd-trie" version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "ucd-util" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "unic-char-property" version = "0.7.0" @@ -1080,6 +1122,11 @@ dependencies = [ "percent-encoding 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", ] +[[package]] +name = "utf8-ranges" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + [[package]] name = "vcpkg" version = "0.2.7" @@ -1162,6 +1209,7 @@ version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] +"checksum aho-corasick 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)" = "81ce3d38065e618af2d7b77e10c5ad9a069859b4be3c2250f674af3840d9c8a5" "checksum aho-corasick 0.7.6 (registry+https://github.com/rust-lang/crates.io-index)" = "58fb5e95d83b38284460a5fda7d6470aa0b8844d283a0b614b8535e880800d2d" "checksum atty 0.2.13 (registry+https://github.com/rust-lang/crates.io-index)" = "1803c647a3ec87095e7ae7acfca019e98de5ec9a7d01343f611cf3152ed71a90" "checksum autocfg 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "1d49d90015b3c36167a20fe2810c5cd875ad504b39cff3d4eae7977e6b7c1cb2" @@ -1186,6 +1234,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum diesel 1.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "9d7cc03b910de9935007861dce440881f69102aaaedfd4bc5a6f40340ca5840c" "checksum diesel_derives 1.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "45f5098f628d02a7a0f68ddba586fb61e80edec3bdc1be3b921f4ceec60858d3" "checksum digest 0.8.1 (registry+https://github.com/rust-lang/crates.io-index)" = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" +"checksum dotenv 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "400b347fe65ccfbd8f545c9d9a75d04b0caf23fec49aaa838a9a05398f94c019" "checksum error-chain 0.12.1 (registry+https://github.com/rust-lang/crates.io-index)" = "3ab49e9dcb602294bc42f9a7dfc9bc6e936fca4418ea300dbfb84fe16de0b7d9" "checksum fake-simd 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" "checksum filetime 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "1ff6d4dab0aa0c8e6346d46052e93b13a16cf847b54ed357087c35011048cc7d" @@ -1245,7 +1294,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum quote 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "053a8c8bcc71fcce321828dc897a98ab9760bef03a4fc36693c231e5b3216cfe" "checksum r2d2 0.8.7 (registry+https://github.com/rust-lang/crates.io-index)" = "22b5c5fc5fba064373f03887337b412e0e1562d63023393db77251146cb75553" "checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" +"checksum regex 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)" = "9329abc99e39129fcceabd24cf5d85b4671ef7c29c50e972bc5afe32438ec384" "checksum regex 1.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "dc220bd33bdce8f093101afe22a037b8eb0e5af33592e6a9caafff0d4cb81cbd" +"checksum regex-syntax 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7d707a4fa2637f2dca2ef9fd02225ec7661fe01a53623c1e6515b6916511f7a7" "checksum regex-syntax 0.6.12 (registry+https://github.com/rust-lang/crates.io-index)" = "11a7e20d1cce64ef2fed88b66d347f88bd9babb82845b2b858f3edbf59a4f716" "checksum ring 0.13.5 (registry+https://github.com/rust-lang/crates.io-index)" = "2c4db68a2e35f3497146b7e4563df7d4773a2433230c5e4b448328e31740458a" "checksum rocket 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)" = "42c1e9deb3ef4fa430d307bfccd4231434b707ca1328fae339c43ad1201cc6f7" @@ -1278,6 +1329,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum typeable 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1410f6f91f21d1612654e7cc69193b0334f909dcf2c790c4826254fbb86f8887" "checksum typenum 1.11.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6d2783fe2d6b8c1101136184eb41be8b1ad379e4657050b8aaff0c79ee7575f9" "checksum ucd-trie 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "8f00ed7be0c1ff1e24f46c3d2af4859f7e863672ba3a6e92e7cff702bf9f06c2" +"checksum ucd-util 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "fa9b3b49edd3468c0e6565d85783f51af95212b6fa3986a5500954f00b460874" "checksum unic-char-property 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ce36d3f7ce754afdbccccf8ff0dd0134e50fb44aaae579f96218856e9e5dbd1e" "checksum unic-char-range 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "d9ab85fab42ad1b26cafc03bf891f69cb4d6e15f491030e89a0122197baa8ae8" "checksum unic-common 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ff8d4a7ade929ef7d971e16ced21a8cd56a63869aa6032dfb8cb083cf7d077bf" @@ -1291,6 +1343,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum unicode-xid 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "826e7639553986605ec5979c7dd957c7895e93eabed50ab2ffa7f6128a75097c" "checksum untrusted 0.6.2 (registry+https://github.com/rust-lang/crates.io-index)" = "55cd1f4b4e96b46aeb8d4855db4a7a9bd96eeeb5c6a1ab54593328761642ce2f" "checksum url 1.7.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dd4e7c0d531266369519a4aa4f399d748bd37043b00bde1e4ff1f60a120b355a" +"checksum utf8-ranges 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "b4ae116fef2b7fea257ed6440d3cfcff7f190865f170cdad00bb6465bf18ecba" "checksum vcpkg 0.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "33dd455d0f96e90a75803cfeb7f948768c08d70a6de9a8d2362461935698bf95" "checksum version_check 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "914b1a6776c4c929a602fafd8bc742e06365d4bcbe48c30f9cca5824f70dc9dd" "checksum version_check 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "078775d0255232fb988e6fccf26ddc9d1ac274299aaedcedce21c6f72cc533ce" diff --git a/server/Cargo.toml b/server/Cargo.toml index 924dcbe..55eeed2 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -12,6 +12,7 @@ serde = "1.0" serde_derive = "1.0" toml = "0.4.2" diesel = { version = "1.4.2", features = ["chrono"] } +dotenv = "0.9.0" [dependencies.rocket_contrib] From 6e5088354c443aedc82a3af4323d4c54652cc17f Mon Sep 17 00:00:00 2001 From: shockrah Date: Mon, 2 Dec 2019 13:47:36 -0800 Subject: [PATCH 2/5] removing fluff idea work --- server/src/db.rs | 58 ------------------------------------------------ 1 file changed, 58 deletions(-) delete mode 100644 server/src/db.rs diff --git a/server/src/db.rs b/server/src/db.rs deleted file mode 100644 index e42febe..0000000 --- a/server/src/db.rs +++ /dev/null @@ -1,58 +0,0 @@ -/* Here we maintain all the different structures that we use to - * interface with our database at any given time - */ - -use diesel::prelude::SqliteConnection; - -enum UserType { - Native, - Remote, - Invalid, -} -#[table_name="users"] -#[derive(Serialize, Queryable, Insertable, Debug, Clone)] -struct User { - userid: String, - /* Sometimes this isn't a password persey - * Basically: native users and remote users will share this here but - * remote users are given a passkey which they don't control. - */ - passkey: String, - native: bool, - display: String, -} - -#[derive(FromForm)] -struct UserRegister{ - userid: String, - display: String, - passkey: String, // basically just a hash for now -} - -struct Ticket { - hashValue: String // probably just some huge text hash -} -impl User { - - /* only ever add a user to our database if they have a ticket whose id matches with - * a currently valid id - * This means that instances can be set to invite only if owners wish - */ - pub fn insert(user: UserLogin, entry: Ticket, conn: &SqliteConnection) -> bool { - } - - pub fn remove(userid: String) -> Result { - } - - pub fn get_user(userid: String) -> Result { - } - - pub fn update_display(userid: String) -> bool { - } - - pub fn update_passkey(userid: String, newpass_hash: String) -> bool { - } - - pub fn update_native(userid: String, newdisplay: String) -> bool { - } -} From 7dde72d3bc501ed56ecfa147ff51eaee5d0577b3 Mon Sep 17 00:00:00 2001 From: shockrah Date: Mon, 2 Dec 2019 13:47:58 -0800 Subject: [PATCH 3/5] dev file which for now poses no quarrel in the repo --- server/.env | 1 + 1 file changed, 1 insertion(+) create mode 100644 server/.env diff --git a/server/.env b/server/.env new file mode 100644 index 0000000..21a74f8 --- /dev/null +++ b/server/.env @@ -0,0 +1 @@ +DATABASE_URL=mysql://freechat:password@localhost/freechat_server From 94ae9804b8daab6951d0d540993f1a053c8f58b7 Mon Sep 17 00:00:00 2001 From: shockrah Date: Mon, 2 Dec 2019 13:48:14 -0800 Subject: [PATCH 4/5] diesel config --- server/diesel.toml | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 server/diesel.toml diff --git a/server/diesel.toml b/server/diesel.toml new file mode 100644 index 0000000..f57985a --- /dev/null +++ b/server/diesel.toml @@ -0,0 +1,2 @@ +[print_schema] +file = "src/schema.rs" From a765f8b9ff94aeb09110559b3f877396ed7c2874 Mon Sep 17 00:00:00 2001 From: shockrah Date: Mon, 2 Dec 2019 13:49:51 -0800 Subject: [PATCH 5/5] more diesel config - db url (localhost url) --- server/Rocket.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/Rocket.toml b/server/Rocket.toml index b84fa7b..84969aa 100644 --- a/server/Rocket.toml +++ b/server/Rocket.toml @@ -9,4 +9,4 @@ port=8080 templates_dir="static/html/" [global.databases.sqlite_dtabase] -url = "db/tmp.sqlite" +url = "mysql://freechat:password@localhost/freechat_server"