From df2b914728a52c1ecccc64612968080616ad5576 Mon Sep 17 00:00:00 2001 From: "me@ow.nekobit.net" Date: Mon, 28 Mar 2022 18:38:10 +0000 Subject: [PATCH] SSL flags FossilOrigin-Name: 744da72a961bbb51926dae5dd1fb1369d95dae876c34ac5e311d2a7d7ec82b6c --- include/mastodont_types.h | 5 +---- src/fetch.c | 6 +++++- src/navigation.c | 34 ++++++++++++++++++++++++++++++++++ src/navigation.h | 26 ++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 5 deletions(-) create mode 100644 src/navigation.c create mode 100644 src/navigation.h diff --git a/include/mastodont_types.h b/include/mastodont_types.h index 6bd6100..83a0c3a 100644 --- a/include/mastodont_types.h +++ b/include/mastodont_types.h @@ -25,11 +25,8 @@ typedef unsigned char mstdnt_bool; #define MSTDNT_FLAG_NO_URI_SANITIZE (1<<0) -#define MSTDNT_FLAG_SSL_NONE (1<<1) #define MSTDNT_FLAG_SSL_UNVERIFIED (1<<2) -#define MSTDNT_FLAG_SSL_EXPIRED (1<<3) -#define MSTDNT_FLAG_SSL_SELFSIGNED (1<<4) -#define MSTDN_FLAG_ISSET(flags, flag) (((flags) & (flag)) == (flag)) +#define MSTDNT_FLAG_ISSET(flags, flag) (((flags) & (flag)) == (flag)) #define MSTDNT_T_FLAG_ISSET(flag_ref, flag) (((flag_ref->flags) & (flag)) == (flag)) typedef struct mastodont diff --git a/src/fetch.c b/src/fetch.c index 8f84454..fcf1f6f 100644 --- a/src/fetch.c +++ b/src/fetch.c @@ -43,7 +43,6 @@ void mastodont_fetch_results_cleanup(struct mstdnt_fetch_results* res) free(res->response); } -#include #define TOKEN_STR_SIZE 512 int mastodont_fetch_curl(mastodont_t* mstdnt, char* _url, @@ -72,6 +71,11 @@ int mastodont_fetch_curl(mastodont_t* mstdnt, curl_easy_setopt(mstdnt->curl, CURLOPT_URL, url); curl_easy_setopt(mstdnt->curl, CURLOPT_WRITEFUNCTION, write_callback); curl_easy_setopt(mstdnt->curl, CURLOPT_WRITEDATA, results); + /* Should we verify the peer's SSL cert? */ + curl_easy_setopt(mstdnt->curl, CURLOPT_SSL_VERIFYPEER, + !MSTDNT_T_FLAG_ISSET(mstdnt, MSTDNT_FLAG_SSL_UNVERIFIED)); + curl_easy_setopt(mstdnt->curl, CURLOPT_SSL_VERIFYHOST, + !MSTDNT_T_FLAG_ISSET(mstdnt, MSTDNT_FLAG_SSL_UNVERIFIED)); /* PUT, POST, GET */ curl_easy_setopt(mstdnt->curl, request_t, 1); diff --git a/src/navigation.c b/src/navigation.c new file mode 100644 index 0000000..870eff3 --- /dev/null +++ b/src/navigation.c @@ -0,0 +1,34 @@ +/* + * Treebird - Lightweight frontend for Pleroma + * Copyright (C) 2022 Nekobit + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "navigation.h" + +#include "easprintf.h" + +// Pages +#include "../static/navigation.chtml" + +char* construct_navigation_box(char* prev_id, char* next_id, size_t size) +{ + char* nav_html; + + size_t s = easprintf(&nav_html, data_navigation_html, + prev_id, + next_id); + if ( +} diff --git a/src/navigation.h b/src/navigation.h new file mode 100644 index 0000000..b3ada73 --- /dev/null +++ b/src/navigation.h @@ -0,0 +1,26 @@ +/* + * Treebird - Lightweight frontend for Pleroma + * Copyright (C) 2022 Nekobit + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#ifndef NAVIGATION_H +#define NAVIGATION_H +#include +#include + +char* construct_navigation_box(char* prev_id, char* next_id, size_t size); + +#endif // NAVIGATION_H