Commit Graph

382 Commits

Author SHA1 Message Date
jfreegman
5619b5e056
Make more functions take const pointers to IP_Port
We additionally now make local copies of the IP_Port param instead
of modifying the passed argument
2022-02-03 11:17:29 -05:00
jfreegman
5880971af8
Make functions take const pointer to IP_Port wherever possible
An IP_Port is a fairly large data structure, and copying them down
the call stack creates a lot of unnecessary overhead.
2022-02-03 10:54:48 -05:00
jfreegman
3a72ed5fae
Properly copy Node_format using serialized format
Also fix a bad comment
2022-02-02 22:00:06 -05:00
iphydf
71965a0f3b
feat: Add WASM build for toxcore and websocket bootstrap node.
The websocket bootstrap node will be running on Heroku.
2022-02-02 16:05:25 +00:00
iphydf
727982d2f9
fix: Fix bootstrap on emscripten/wasm.
Also added a whole bunch of logging that I needed while debugging the
issue. The solution in the end is that bootstrap needs to resolve IPs,
and getaddrinfo fails in the browser. Most of the time we bootstrap
against IPs anyway, so trying to parse as IP address first will shortcut
that.
2022-02-01 21:00:09 +00:00
jfreegman
52c31efb97
Small refactor of DHT getnodes function 2022-01-29 16:52:25 -05:00
jfreegman
3f4ea3d5fd
Remove brackets from ip_ntoa ipv6 formatting
The brackets serve no purpose and make us do extra string
parsing when using the output for other things

Also removed a useless call to ip_ntoa in LAN_discovery.c
2022-01-29 15:29:14 -05:00
jfreegman
8c3bd7fc35
Fix some unintentional integer down-casts
None of these currently cause any bugs from what I
can see, but they're still incorrect.
2022-01-28 09:57:17 -05:00
Tha14
5a88159b8f
Pass "b" for fopen to fix bugs on windows 2022-01-24 16:00:01 +02:00
iphydf
7f94e411a9
chore: Add cpplint to the CI. 2022-01-17 23:42:38 +00:00
jfreegman
fc18810ba8
Fix buffer overwrite in bootstrap config 2022-01-17 17:56:47 -05:00
iphydf
9dfad80017
cleanup: Remove our only use of flexible array members in toxcore.
We still have them in toxav. That will need to be cleaned up later.
Flexible array members have very limited usefulness. In this particular
case, it's almost entirely useless. It confuses static analysers and is
yet one more C feature we need to understand and support. It is also the
only reason we need special support in tokstyle for calloc with a `+`
operator in the member size.
2022-01-17 18:37:16 +00:00
iphydf
5fbcbb6c83
cleanup: Remove uses of strcpy and sprintf.
Use of `strcpy` in these particular cases was safe, but it's hard to
tell and also useless. `strcpy` would effectively need to do another
`strlen` which we already did.

Also removed sprintf, which was also safe in this case but it's easier to
be "obviously safe", especially for static analysers.
2022-01-17 18:25:40 +00:00
iphydf
4ce02c0af9
refactor: Deduplicate a bunch of code in TCP client/server.
Also generally a bit of cleanup and better layering.
2022-01-16 09:41:08 +00:00
iphydf
422c8d1125
cleanup: Make parameters pointers-to-const where possible. 2022-01-16 01:28:25 +00:00
iphydf
09bb9b8a23
cleanup: Make Networking_Core pointer-to-const where possible. 2022-01-16 01:09:44 +00:00
iphydf
c081a50201
cleanup: Use pointer cast instead of memcpy in qsort callback.
No need to make copies of the data. There is no concurrency in qsort.
2022-01-16 00:12:44 +00:00
iphydf
0d27eb2f90
cleanup: Deduplicate a somewhat complex loop in DHT.c. 2022-01-15 21:25:14 +00:00
iphydf
2671095f4a
cleanup: Merge crypto_core and crypto_core_mem.
The remaining memory functions are small and don't need their own file.
2022-01-15 01:34:14 +00:00
iphydf
6823fcbae1
cleanup: Stop using strerror directly.
We have a more portable wrapper that is now also thread-safe. Also
stopped using sprintf in the one place we used it. This doesn't really
help much, but it allows us to forbid sprintf globally.
2022-01-15 01:25:56 +00:00
iphydf
8d19757f8e
chore: Add mypy Python type check.
Also fix the types in all Python files.
2022-01-14 19:55:37 +00:00
iphydf
4a2cb37e4b
fix: Fix some uninitialised memory errors found by valgrind and msan.
Also added a valgrind build to run it on every pull request. I've had to
disable a few tests because valgrind makes those run infinitely slowly,
consistently timing them out.
2022-01-13 20:15:21 +00:00
iphydf
c1b32bd7a1
chore: Enable compiler layering check.
This ensures that we're explicit about what we depend on and avoids
transitive dependencies.
2022-01-11 15:26:32 +00:00
sudden6
faf39ef94f
update tox-bootstrapd.sha256
__LINE__ macros were changed due to inserting #ifdef
2022-01-10 21:05:51 +01:00
iphydf
f46f51e554
cleanup: Don't use memcpy where assignment can be used.
See https://github.com/TokTok/hs-tokstyle/pull/104.
2022-01-10 10:58:42 +00:00
Robin Linden
23df660fd2
Remove always-true check in receivepacket error handling 2022-01-10 02:27:13 +01:00
iphydf
73484d8995
cleanup: Use calloc instead of malloc for struct allocations.
`malloc` is used only for byte/int arrays. Also, we no longer allow plain
`void *` allocations. Every allocation should have a real value type.
2022-01-09 22:42:50 +00:00
iphydf
83d5d0d280
cleanup: Remove useless parentheses. 2022-01-06 20:36:03 +00:00
jfreegman
7318127dca
Remove dead code
Neither of these clauses can ever be reached.

Also attempt to fix travis Windows build
2022-01-01 19:44:11 -05:00
iphydf
8cd4827a14
cleanup: Reduce the scope of for-loop iterator variables.
Found by tokstyle after https://github.com/TokTok/hs-tokstyle/pull/95.
2022-01-01 03:26:41 +00:00
iphydf
6f61de54d3
chore: Add "tcc" and "compcert" compiler targets.
It's nice we are able to compile with `tcc`. Let's not break that.
CompCert is also neat, but its interpreter mode doesn't work on tox, so
we only use the compiler.
2021-12-30 23:09:23 +00:00
iphydf
1e11865c4c
chore: Add bootstrap daemon docker image build.
This will also push to dockerhub on merge.
2021-12-23 15:54:24 +00:00
Maxim Biro
064ec836fe
Make CodeFactor happy 2021-12-14 08:55:53 -05:00
Maxim Biro
805858716e
Fix file permission issue in toxchat/bootstrap-node
/var/lib/tox-bootstrapd on the host is owned by hosts's tox-bootstrapd
and chowned 700, but the container attempts to access it as its own
tox-bootstrapd user with possibly different uid:gid, which will fail if
host's tox-bootstrapd user has different uid:gid than the tox-bootstrapd
user inside the container.

This change makes the container use host's tox-bootstrapd uid:gid, which
fixes the issue.
2021-12-14 08:55:52 -05:00
Maxim Biro
0538273479
Update base images of toxchat/bootstrap-node 2021-12-14 08:55:48 -05:00
iphydf
30c939e4ab
cleanup: Fix some clang-tidy warnings and make them errors.
The android warnings are disabled now because they suggest using
linux-only extensions of libc. Useful for android indeed, but we're
targeting non-android and non-linux systems as well.
2021-12-10 15:21:27 +00:00
iphydf
fd91bbdd7b
test: Add a simple test for ip_ntoa.
Just to demonstrate that it will never exceed its input buffer.
2021-12-09 20:51:15 +00:00
Maxim Biro
4e8e556a93
Fix previous refactor
Includes should be sorted alphabetically and null-terminating is
unnecessary with snprintf.
2021-12-09 13:23:06 -05:00
jfreegman
edf9d66717
Add logger to onion and onion announce objects
This will be used in the future
2021-12-07 13:01:15 -05:00
Robin Linden
4348b96a5b
Release 0.2.13 2021-12-06 23:28:52 +01:00
sudden6
0320e2eb8e
fix missing braces in computed macro value
Using this value in any computation might not work as expected.
2021-12-05 14:20:04 +01:00
jfreegman
00f2f41dbb
Use heap memory instead of stack for large variables
The default stack size for musl-libc is 128kb. Therefore we should try to keep stack
allocations well below this limit in order to avoid stack overflows.
2020-11-20 19:15:58 -05:00
Robin Linden
5d2b1e3861
Update tox-bootstrapd checksum due to newer packages in Alpine
* g++       9.2.0-r4  -> 9.3.0-r0
* gcc       9.2.0-r4  -> 9.3.0-r0
* libatomic 9.2.0-r4  -> 9.3.0-r0
* libcurl   7.67.0-r0 -> 7.67.0-r1
* libgcc    9.2.0-r4  -> 9.3.0-r0
* libgomp   9.2.0-r4  -> 9.3.0-r0
* libstdc++ 9.2.0-r4  -> 9.3.0-r0
* python3   3.8.2-r0  -> 3.8.2-r1
2020-11-16 16:22:55 +01:00
iphydf
8c0fd40356
refactor: Remove multi-declarators entirely.
We no longer allow `int a, b;`. In the few cases where we used it, we
instead better

* limit the scope of the identifier (e.g. in a for-init-decl)
* split the line and have 2 separate declarators, because the
  identifiers designate different types of things (e.g. friend numbers
  and group numbers).
2020-05-05 23:22:29 +01:00
iphydf
48bd200acb
refactor: Disallow multiple initialised declarators per decl.
We no longer allow:

```c
int a = 0, b = 0;
int a[3], b[3];
int a, *b;
```

But we do still allow (for now):

```c
int a, b;
```
2020-05-05 22:56:35 +01:00
iphydf
c1a2ea3309
Use bash arrays instead of strings for static analysis scripts.
These are more robust wrt. spaces in names.
2020-05-05 01:53:01 +01:00
iphydf
02a5bdc60c
Add logging to TCP and onion client. 2020-05-04 01:27:36 +01:00
iphydf
88b90c8225
Fix a bug in savedata loading when malloc fails.
Also added a bunch of asserts to tests where they don't check allocs.
2020-05-03 14:13:48 +00:00
iphydf
f8ab32aaa4
Add a check that we don't have any unused functions.
This check puts all of our code in a C++ anonymous namespace, which is
effectively making all functions `static`. This allows the compiler to
determine that a function is unused, so we can delete it.
2020-05-02 22:00:09 +01:00
iphydf
2570ddcb17
Fix errors on error paths found by oomer.
* Use-after-free because we free network before dht in one case.
* Various unchecked allocs in tests (not so important).
* We used to not check whether ping arrays were actually allocated in DHT.
* `ping_kill` and `ping_array_kill` used to crash when passing NULL.

Also:
* Added an assert in all public API functions to ensure tox isn't NULL.
  The error message you get from that is a bit nicer than "Segmentation
  fault" when clients (or our tests) do things wrong.
* Decreased the sleep time in iterate_all_wait from 20ms to 5ms.
  Everything seems to still work with 5ms, and this greatly decreases
  the amount of time spent per test run, making oomer run much faster.
2020-05-02 21:47:08 +01:00
Robin Linden
9be4dbb433
Release 0.2.12 2020-05-01 12:58:27 +02:00
iphydf
a2d586b782
Rework the toxchat/bootstrap-node Docker image.
* Use fully static build for the bootstrap daemon.
* Store a sha256sum of the binary in the repo.
* Updated documentation for it.
* Add support for fully static build in cmake.
* Enable the docker build on every PR, so we catch changes to the
  checksum. I realise this is adding toil, but having the checksum is
  valuable for security of released binaries.
2020-04-26 16:13:24 +00:00
iphydf
11ad5471b9
Use spdx license identifier instead of GPL blurb. 2020-03-14 13:06:19 +00:00
iphydf
e671490989
Use rules_cc instead of native cc_library rules. 2020-03-12 12:20:54 +00:00
Maxim Biro
7c63b0f734
Update tox-bootstrapd's dockerfile to use Debian Buster 2020-03-03 01:23:24 -05:00
Maxim Biro
ac5c9ebce4
Fix tox-bootstrapd's README 2020-03-03 01:23:22 -05:00
Maxim Biro
5530e41742
Increase NOFILE limit for tox-bootstrapd
tox-bootstrapd can use around 600 TCP sockets during TCP server's normal
functioning. Many systems default to having a soft limit of 1024 open file
descriptors, which we are close to reaching, so it was suggested we bump that
limit to a higher number. iphy suggested increasing it to 32768.
2018-11-04 20:10:09 -05:00
Maxim Biro
b6dde3c76f
Use cmake to build toxcore in tox-boostrapd's Dockerfile 2018-10-17 14:45:44 -04:00
Maxim Biro
9b98ac1342
tox-bootstrapd's Dockerfile shouldn't use master branch 2018-10-17 14:45:36 -04:00
Maxim Biro
1cbc9609a7
Make tox-bootstrapd free memory on SIGINT and SIGTERM
Useful for using memory analyzing tools.
2018-10-16 21:35:27 -04:00
iphydf
77e025fae4
Remove Alpine Linux bootstrap daemon dockerfile.
We can add it back when there is a test for it. For now, we don't know
whether it works and don't have tests to make sure it keeps working.
2018-10-08 23:00:35 +00:00
iphydf
49bb43f662
Standardise header guards.
Using the full path including the repo name.
2018-09-14 19:09:10 +00:00
Maxim Biro
2e4cae692e
Use our own logging facility to log toxcore's logs 2018-08-30 22:44:18 +00:00
cotox
deb82006e5
Feature bootstrap trace/debug log output
Don't know why codes with macro dosen't work.
As it's only a few expensive, just code it without macro for now.

\#if (MIN_LOGGER_LEVEL == LOG_TRACE) || (MIN_LOGGER_LEVEL == LOG_DEBUG)
    fprintf(stderr, "[%s] %s:%d(%s) %s\n", strlevel, file, line, func, message);
\#endif
2018-08-30 22:44:18 +00:00
iphydf
473cde24d8
Update copyright to 2018. 2018-08-26 18:57:29 +00:00
iphydf
d6d305feeb
Use per-instance Mono_Time for Messenger and onion. 2018-08-16 21:01:43 +00:00
iphydf
54066f338f
Reduce the number of times unix_time_update is called.
Reduced by, e.g.:
* `file_transfer_test`: 33% of the `clock_gettime` calls.
* `tox_many_test`: 53% of the `clock_gettime` calls.

Other tests will see similar improvements. Real world applications will
be closer to 40-50% improvement, since tox_many_test has 100 nodes, while
file_transfer_test has 2 nodes.
2018-08-16 21:01:38 +00:00
iphydf
d92c96e783
Fix a few warnings from clang.
Also remove the use of a VLA in a context where there can be unbounded
memory allocations.
2018-08-12 14:09:59 +00:00
iphydf
f627a26a7b
Run Clang global static analysis on Travis.
This uses a single .cc file containing almost all the code in the
repository to perform whole program analysis.
2018-07-22 02:34:30 +00:00
iphydf
abc17b0f89
Factor out time keeping code into its own module: mono_time.c.
It turns out, `unix_time` is also monotonic, and is used as such, so I've
renamed the new functions to `mono_time_*`.

2018-07-08:
```
00:01 <@irungentoo> the idea used to be that the unix_time() function
  could go backward in time but I think I might have started using it like
  if it could not after I changed it so that it would never go back in time
```
2018-07-09 21:04:50 +00:00
iphydf
8739f7fccb
Make tox.c unambiguously parseable.
Rules:
1. Constants are uppercase names: THE_CONSTANT.
2. SUE[1] types start with an uppercase letter and have at least one
   lowercase letter in it: The_Type, THE_Type.
3. Function types end in "_cb": tox_friend_connection_cb.
4. Variable and function names are all lowercase: the_function.

This makes it easier for humans reading the code to determine what an
identifier means. I'm not convinced by the enum type name change, but I
don't know a better rule. Currently, a lot of enum types are spelled like
constants, which is confusing.

[1] struct/union/enum
2018-07-05 23:09:28 +00:00
iphydf
1a54be06cd
Simplify Travis CI builds.
Have one script per build. This means more duplication between the
scripts, but it's much easier to understand and to run locally.
2018-07-01 08:35:44 +00:00
Maxim Biro
7684b5ae3e
Make bootstrap daemon use toxcore's version 2018-06-25 00:29:16 -04:00
cotox
2d0a21adb3
Fix bootstrap logger
TODO: need a meanful log output
2018-05-22 01:01:18 +08:00
iphydf
4f6ab0708c
Add empty logger to DHT bootstrap daemons.
These should register a proper logging callback so the messages don't go
devnull, but this at least ensures a logger is available.
2018-05-20 16:15:49 +00:00
iphydf
aa05095419
Remove the use of the 'hh' format specifier.
It's not supported in mingw.

See https://github.com/TokTok/c-toxcore/issues/786.
2018-03-16 01:57:26 +00:00
iphydf
6cd4fcdec4
Remove libcheck from the dependencies.
We're not gaining much from this library, and it's a burden, especially
for windows development.
2018-02-09 20:51:39 +00:00
iphydf
92ffad1a72
Use nullptr as NULL pointer constant instead of NULL or 0.
This changes only code, no string literals or comments.
2018-01-30 23:35:50 +00:00
iphydf
6e0ac337c9
Avoid clashes with "build" directories on case-insensitive file systems. 2018-01-28 15:17:34 +00:00
iphydf
e6c04ef028
Use self-built portaudio instead of system-provided. 2018-01-22 00:44:19 +00:00
iphydf
1cecb6c87a
Add BUILD files for all the little tools in the repo.
Also, fix av_test.c, since I broke it last time.
2018-01-21 01:31:11 +00:00
iphydf
d7583a719a
Remove nTox from the repo.
It's a maintenance burden nobody uses. Let's make toxic the official
console client, instead.
2018-01-20 19:05:53 +00:00
iphydf
643eea60bb
Make DHT a module-private type. 2018-01-16 20:06:07 +00:00
iphydf
0b13936ce8
Use apidsl to generate LAN_discovery.h. 2018-01-16 14:17:05 +00:00
romik-g
6fc0be5142
Add Alpine Linux Dockerfile 2018-01-16 10:17:16 +00:00
Maxim Biro
418a304c0e Update tox-bootstrapd Dockerfile 2017-12-16 03:14:23 -05:00
Maxim Biro
b0aec02225 Split daemon's logging backends in separate modules 2017-06-04 16:07:03 -04:00
Maxim Biro
f6285d7a60 Fix markdown formatting 2017-04-19 20:22:28 -04:00
Diadlo
b19a9e5464
Add part of platform-independent network API implementation
socket      -> net_socket
htons       -> net_htons
htonl       -> net_htonl
connect     -> net_connect
sendto      -> net_sendto_ip4
getaddrinfo -> net_getipport
sa_family_t -> Family
2017-02-26 23:16:16 +03:00
iphydf
6ae33c16cf
Add VLA compatibility macro for C89-ish compilers. 2017-01-28 20:49:12 +00:00
iphydf
8f96ca6d86
Update license headers and remove redundant file name comment.
"All rights reserved" was incorrect. The project was licensed under GPL3,
which means a lot of rights are licensed to everybody in the world, i.e.
not reserved to the "Tox Project".
2017-01-19 00:01:44 +00:00
David Zero
8ef1f35ca7 Revert "Revert "Portability fixes""
This reverts commit 59e2a844f0, and
defines _DARWIN_C_SOURCE in toxcore/network.c
2017-01-06 04:20:00 -08:00
endoffile78
59e2a844f0 Revert "Portability fixes"
This reverts commit f3469070fe.
2017-01-05 15:16:56 -06:00
David Zero
f3469070fe Portability fixes
- CFLAG gnu99 was changed to c99.
- CXXFLAG c++98 was changed to c++11.
- CFLAG -pedantic-errors was added so that non-ISO C now throws errors.
- _XOPEN_SOURCE feature test macro added and set to 600 to expose SUSv3
  and c99 definitions in modules that required them.
- Fixed tests (and bootstrap daemon logging) that were failing due to
  the altered build flags.
- Avoid string suffix misinterpretation; explicit narrowing conversion.
- Misc. additions to .gitignore to make sure build artifacts don't wind
  up in version control.
2017-01-04 13:44:39 -08:00
iphydf
ce29c8e7ec
Wrap all sodium/nacl functions in crypto_core.c. 2016-12-22 10:26:59 +00:00
Gregory Mullen (grayhatter)
ad517eb1df
add NAT hole punching level to Tox API 2016-11-24 17:38:34 -08:00
iphydf
1977d56caa
Remove return after no-return situation (and other cleanups).
Cleanups:
- Fix header guards to not use reserved names.
- Avoid name shadowing.
- Removed an unused variable found by avoiding name shadowing.
2016-09-30 19:06:44 +01:00
iphydf
30e86c5eb0
Merge branch 'master' of https://github.com/irungentoo/toxcore 2016-09-29 09:54:53 +01:00
iphydf
15cb426166
Make toxcore code C++ compatible.
It is still C code, so still compatible with C compilers as well. This
change lets us see more clearly where implicit conversions occur by
making them explicit.
2016-09-24 21:53:50 +01:00
iphydf
0d347c2b2e
Minor cleanups: unused vars, unreachable code, static globals.
- All global variables should be static unless they have an explicit
  extern declaration in a header file.
- `to_compare` was not used in encryptsave and toxav tests.
- `break` in switch cases is not required directly after `return`,
  `goto`, or a noreturn function like `abort`.
2016-09-24 20:52:09 +01:00
arza
d28f94a2f9 Changed the umask to 077 so that the keys file is not readable/writable by other users. 2016-09-19 05:03:48 +03:00
arza
3df21424bb Included sys/stat.h. 2016-09-19 05:03:38 +03:00
iphydf
406d292107
Minor cleanups: header reordering, adding {}.
I hadn't done this for the "fun" code, yet. Also, we should include
system headers after our own headers.

"In general, a module should be implemented by one or more .cpp files.
Each of these .cpp files should include the header that defines their
interface first. This ensures that all of the dependences of the module
header have been properly added to the module header itself, and are not
implicit. System headers should be included after user headers for a
translation unit."
-- http://llvm.org/docs/CodingStandards.html#a-public-header-file-is-a-module
2016-09-09 19:30:50 +01:00
iphydf
ad26560516
Improve static and const correctness.
- Any non-externally-visible declarations should be `static`.
- Casting away the `const` qualifier from pointers-to-const is
  dangerous. All but one instance of this are now correct. The one
  instance where we can't keep `const` is one where toxav code actually
  writes to a chunk of memory marked as `const`. This code also assumes
  4 byte alignment of data packets. I don't know whether that is a valid
  assumption, but it's likely unportable, and *not* obviously correct.
- Replaced empty parameter lists with `(void)` to avoid passing
  parameters to it. Empty parameter lists are old style declarations for
  unknown number and type of arguments.
- Commented out (as `#if DHT_HARDENING` block) the hardening code that
  was never executed.
- Minor style fix: don't use `default` in enum-switches unless the number
  of enumerators in the default case is very large. In this case, it was
  2, so we want to list them both explicitly to be warned about missing
  one if we add one in the future.
- Removed the only two function declarations from nTox.h and put them
  into nTox.c. They are not used outside and nTox is not a library.
2016-09-06 11:54:37 +01:00
iphydf
5b57ab6332
Improve C standard compliance.
- Don't cast between object and function pointers.
- Use standard compliant `__VA_ARGS__` in macros.
- Add explicit `__extension__` on unnamed union in struct (it's a GNU
  extension).
- Remove ; after function definitions.
- Replace `const T foo = 3;` for integral types `T` with `enum { foo = 3 };`.
  Folding integral constants like that as compile time constants is a GNU
  extension. Arrays allocated with `foo` as dimension are VLAs on strictly
  compliant C99 compilers.
- Replace empty initialiser list `{}` with zero-initialiser-list `{0}`.
  The former is a GNU extension meaning the latter.
- Cast `T*` (where `T != void`) to `void *` in format arguments. While any
  object pointer can be implicitly converted to and from `void *`, this
  conversion does not happen in variadic function calls.
- Replace arithmetic on `void *` with arithmetic on `char *`. The former
  is non-compliant.
- Replace non-`int`-derived types (like `uint16_t`, which is
  `short`-derived) in bit fields with `int`-derived types. Using any type
  other than `int` or `unsigned int` (or any of their aliases) in bit
  fields is a GNU extension.
2016-09-06 11:09:10 +01:00
iphydf
77db27331e
Sort #includes in all source files. 2016-09-01 16:35:46 +01:00
iphydf
576f130615
Remove redundant return statements. 2016-08-31 23:51:39 +01:00
iphydf
633da98ae6
Add braces to all if statements. 2016-08-31 20:04:16 +01:00
iphydf
13ae9e9a93
Move logging to a callback.
This removes the global logger (which by the way was deleted when the first tox
was killed, so other toxes would then stop logging). Various bits of the code
now carry a logger or pass it around. It's a bit less transparent now, but now
there is no need to have a global logger, and clients can decide what to log and
where.
2016-08-27 01:16:14 +01:00
iphydf
6935643f9a
Fix some compiler warnings. 2016-08-18 17:10:15 +01:00
iphydf
a5e35180c7
Make tox_callback_friend_name stateless.
See #27 and #40 for details.
2016-08-18 00:01:53 +01:00
iphydf
c603c8c9e7
Merge remote-tracking branch 'irungentoo/master' 2016-08-17 20:52:10 +01:00
iphydf
459f8f2013
Check code formatting on Travis.
We run astyle on Travis and check if there is a diff. The build terminates if
git finds a difference.
2016-08-12 01:00:00 +01:00
LittleVulpix
88f29aaa9f Documentation: SysVInit workaround for <1024 ports
Update the manual to provide a command necessary to open <1024 ports for users on SysVinit
2016-07-11 11:34:32 +02:00
LittleVulpix
98446e0818 Documentation: SysVInit workaround for <1024 ports
Update the manual to provide a command necessary to open <1024 ports for users on SysVinit
2016-07-10 22:56:00 +02:00
irungentoo
aafeb7ddd8
Merge branch 'make-dist' of https://github.com/roman-yepishev/toxcore 2016-03-13 22:07:50 -04:00
romik-g
c2b2142f33 Changes from @nurupo for build and runtime dependencies that reduce image size
Also removal of example bootstrap nodes from the config file in one line
2016-03-03 13:30:11 -05:00
romik-g
739975dc3d Re-format to reduce image file by 50% 2016-03-03 13:29:24 -05:00
Roman Yepishev
b0e720846f
Add missing files so that archive for make dist is complete 2016-02-26 22:58:13 -05:00
Ferdinand Thiessen
a8873ed4fd Fix #1520: Program returns random data in a function
Added default return to non void functions level_syslog and level_stdout.
2016-02-05 22:31:34 +01:00
Maxim Biro
c597f0786d Add missing newline 2016-01-24 01:33:53 -05:00
irungentoo
405854e1e7
Cleanups. 2016-01-04 22:48:58 -05:00
Maxim Biro
9d1efd5949 Change init.d to SysVinit 2016-01-02 18:55:53 -05:00
Maxim Biro
516d5ac09d Add information on how to update the bootstrap daemon 2016-01-02 18:46:52 -05:00
Maxim Biro
6c104b5fe3 Keep it in alphabetical order 2016-01-01 21:10:20 -05:00
Maxim Biro
f74d7c5ae6 Version bump 2016-01-01 20:29:24 -05:00
Maxim Biro
1b721ea1ec Add Dockerfile for the daemon 2016-01-01 20:29:24 -05:00
Maxim Biro
c22c06adbe Flush stdout output
Apparently when no tty is attached, which is the case for Docker, the
buffer size for stdout increases to the point that only half of the
entire log might be written.
2016-01-01 20:29:24 -05:00
Maxim Biro
5d9e40bbd3 Unify function comment style
Use doxygen java-style function comments already used in log.[c|h].
2016-01-01 20:29:24 -05:00
Maxim Biro
232488816e Fix license headers and file descriptions 2016-01-01 20:29:18 -05:00
Maxim Biro
d89fdb230b Fix include paths
They are relative to the Makefile instead of the source file itself,
which is unintuitive and is messing with my IDE.
2016-01-01 20:28:48 -05:00
Maxim Biro
da76da6c95 Remove dependency on files from testing directory
Also remove unneeded includes and refactor sleep define.
2016-01-01 00:55:09 -05:00
Maxim Biro
7d86caf51f Put command-line arguments related functions in a separate file 2016-01-01 00:36:57 -05:00
Maxim Biro
6b40a581b1 Put config-related functions in a separate file
bootstrap_node_packets.c was giving an error as it was being included
twice and there were no include guards, so part of it was split into
bootstrap_node_packets.h.
2016-01-01 00:19:35 -05:00
Maxim Biro
e1fc8c1d3c Add ability to run the daemon in foreground
Useful for things like a Docker container or just running it in the
terminal.

Complements the stdout logging option. This is actually why the stdout
logging was added in the first place -- to be used in the foreground
mode, though nothing stops one from using stdout in the background
mode, which one could redirect to a file.
2015-12-31 23:18:39 -05:00
Maxim Biro
2ef1ce9421 Fix wrong filename mentioned above license 2015-12-31 20:06:37 -05:00
Maxim Biro
ffa927fa36 Rename LOGGER_BACKEND to LOG_BACKEND 2015-12-31 20:01:24 -05:00
Maxim Biro
a40fd1bb6c Add ability to specify multiple command line arguments
Needed in order to specify which log backend to use.

Init scripts need to be updated to contain --config before the path to
the config file.
2015-12-31 19:58:34 -05:00
Maxim Biro
8c812f5341 Make daemon use the new log code
"log" is a reserved name (log from math.h), so it got changed into
write_log.
2015-12-31 02:44:44 -05:00
Maxim Biro
c50781a2b7 Make logger a global object instead of an instance
Passing Logger object into every function isn't fun. See for yourself:
something as simple as a public key printing function turns from
>void print_public_key(const uint8_t *public_key)
to
>void print_public_key(Logger *logger, const uint8_t *public_key)
2015-12-31 01:24:31 -05:00
Maxim Biro
bfc3c4eaac Add logger object to be able to support multiple logging backends 2015-12-30 23:43:04 -05:00
Maxim Biro
78d6e2d58b Change log levels
Some of them were set incorrectly, e.g. something that caused the
daemon to exit was marked as just a warning, instead of an error.

Removed debug level as it was hard to decide whether something should
go into info or debug. This is mostly because the use of the debug level
wasn't well defined. Debug should be used for information that could
help a user to debug an issue, but messages marked as debug were by the
most part the "success" log messages, which could go into info level
instead.
2015-12-30 21:49:00 -05:00
irungentoo
749a9330c4
Link changes. 2015-07-07 22:57:11 -04:00
irungentoo
50e0802a62
Removed useless parameter from new_TCP_server() 2015-06-28 22:14:54 -04:00
irungentoo
8a32b3a12f
Merge branch 'bootstrapd-update2' of https://github.com/nurupo/InsertProjectNameHere 2015-05-24 21:00:45 -04:00
irungentoo
06188e9818
Fixed segfault in tox-bootstrapd. 2015-05-13 10:45:16 -04:00
Maxim Biro
86cd3141d0 Updated daemon's systemd file, fixed typos in README
@arthurtiteica has pointed out that systemd has more suitable facilities for
creating a temporary directory for a PID file rather than calling  ExecStartPre,
which requires an absolute path to coreutils executables we used for creating a
directory and changing its owner, paths of which are are not universal across
distributions. Systemd can take care of it for us without need to provide
absolute paths, which is what we use here.
2015-05-10 03:04:42 -04:00
Eugene Lopatin
159df4b23c Documentation and service description for using tox-bootstrapd with
systemd
2015-02-05 12:43:24 +06:00
Maxim Biro
51b8ac8460 Replace hardcoded nodes with examples
Reverts Proplex'es change.
2015-01-25 18:31:44 -05:00
irungentoo
6114bd7f3e
Merge branch 'tox-bootstrapd-network-error-handling' of https://github.com/nurupo/InsertProjectNameHere 2014-10-15 20:01:43 -04:00
Maxim Biro
e8d7763e92 Don't fail when the binary is not found
Per Debian Policy Manual, paragraph 9.3.2: Writing the scripts.
2014-10-14 14:14:06 -04:00
Maxim Biro
fd255ee6c5 Fixed a typo 2014-10-13 01:10:36 -04:00
Maxim Biro
2bdbc2bf1b Added some const-correctnessness 2014-10-13 00:59:00 -04:00
Maxim Biro
e677bbc89e Fixed a typo 2014-10-12 23:31:20 -04:00
Maxim Biro
1200e69a3f Added IPv4 fallback, made IPv6 and IPv4 fallback enabled by default 2014-10-12 23:22:25 -04:00
Maxim Biro
09302e8909 Free ports when there are no valid ones 2014-10-12 19:21:22 -04:00
irungentoo
0444ca18df
Merge branch 'master' of https://github.com/stqism/ToxCore 2014-10-11 18:59:09 -04:00
Sean Qureshi
2df986f6b9 Does a realloc with a size of 0 if every port is invalid 2014-10-10 18:23:23 -07:00
Sean Qureshi
532ace635a Enable IPv6, fix systemd PID bug 2014-10-10 18:09:52 -07:00
David Lohle
cc5453edbd Add working tox nodes
since the daemon is in the process of being packaged for easy deployment, it's probably best we have a working default config that extends existing nodes.
2014-10-06 03:16:55 -04:00
cgar
2bb2bc4163 spelling corrections 2014-09-09 20:31:37 -04:00
Maxim Biro
02f90fc604 Added .sh ending to bootstrapd's init script
Fixes some build issues.
2014-08-18 22:24:42 -04:00
Maxim Biro
d00c3c32d2 Fixed some warnings 2014-08-17 15:59:37 -04:00
Maxim Biro
504160ee57 Fixed daemon taking long time to stop 2014-08-17 02:17:03 -04:00
Maxim Biro
69e619bfa0 Renamed files for less confusion 2014-08-17 01:58:24 -04:00
Maxim Biro
ba7058c891 Made possible to run the daemon under its own user 2014-08-17 01:53:54 -04:00
Maxim Biro
e474a32e71 Made init.d script work with systemd 2014-08-17 00:12:35 -04:00
Maxim Biro
2040fc41d2 Renamed tox_bootstrap_daemon into tox-bootstrapd 2014-08-16 23:19:23 -04:00
irungentoo
9b2d3e50b2
Merge branch 'bootstrap_daemon-leaks-1' of https://github.com/tux3/toxcore into tux3-bootstrap_daemon-leaks-1 2014-06-19 16:23:00 -04:00
Tux3 / Mlkj / !Lev.uXFMLA
4c12ee3e30 Fix scope, ressource leaks in boostrap daemon
Reduce scope of config_setting_t *elem

Fix various leaks of files keys_file and pid_file
2014-06-18 23:38:38 +02:00
stal
83d4d8ea5d Install tox_bootstrap_daemon
I call on the venerable @jin_eld once again to verify that this change is correct.
2014-05-20 18:57:20 -07:00
Maxim Biro
286d8d9661 Made config file more consistent with default values 2014-05-18 21:04:42 -04:00
Maxim Biro
fe1694fa69 Added default ports to the .c file, included 33445 port 2014-05-18 19:59:01 -04:00
Maxim Biro
261a70353f Fixed a bug 2014-05-18 19:59:01 -04:00
Maxim Biro
8b5e3d5208 Allow multiple instances of the daemon 2014-05-18 19:58:57 -04:00
irungentoo
906969d376
Fixed out of bounds write. 2014-05-18 14:43:32 -04:00
Maxim Biro
7dd811214a Added MOTD functionality 2014-05-18 00:38:20 -04:00
Maxim Biro
e75930e72e Some small fixes 2014-05-17 21:49:57 -04:00
Maxim Biro
8be6b0986d Extracted min and max allowed port values into named constants 2014-05-17 21:49:51 -04:00
Maxim Biro
ceaeae8cff Added TCP server functionality 2014-05-17 20:36:16 -04:00
irungentoo
2aa3cdfc69
Fixed the DHT bootstrap daemon. 2014-04-23 12:47:57 -04:00
Maxim Biro
5a142bb697 Renamed dht server to dht node 2014-02-22 17:07:15 -05:00