Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tg
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
tg
Commits
29ed574e
Commit
29ed574e
authored
Dec 20, 2013
by
vysheng
Browse files
Options
Browse Files
Download
Plain Diff
Merge
https://github.com/lwhsu/tg
parents
41fc7c22
d9526567
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
33 additions
and
150 deletions
+33
-150
.gitignore
.gitignore
+2
-0
Makefile
Makefile
+0
-35
Makefile.in
Makefile.in
+2
-2
README.md
README.md
+12
-0
config.h
config.h
+0
-106
loop.c
loop.c
+1
-0
mtproto-client.c
mtproto-client.c
+12
-6
net.c
net.c
+4
-1
No files found.
.gitignore
0 → 100644
View file @
29ed574e
Makefile
config.h
Makefile
deleted
100644 → 0
View file @
41fc7c22
srcdir
=
.
CFLAGS
=
-g
-O2
LDFLAGS
=
CPPFLAGS
=
DEFS
=
-DHAVE_CONFIG_H
COMPILE_FLAGS
=
${
CFLAGS
}
${
CPPFLAGS
}
${
DEFS
}
-Wall
-Wextra
-Werror
-Wno-deprecated
-fno-strict-aliasing
-fno-omit-frame-pointer
-ggdb
EXTRA_LIBS
=
-lreadline
-lrt
-lconfig
LOCAL_LDFLAGS
=
-lm
-lcrypto
-lz
-lssl
-rdynamic
-ggdb
${
EXTRA_LIBS
}
LINK_FLAGS
=
${
LDFLAGS
}
${
LOCAL_LDFLAGS
}
HEADERS
=
${
srcdir
}
/constants.h
${
srcdir
}
/include.h
${
srcdir
}
/interface.h
${
srcdir
}
/LICENSE.h
${
srcdir
}
/loop.h
${
srcdir
}
/mtproto-client.h
${
srcdir
}
/mtproto-common.h
${
srcdir
}
/net.h
${
srcdir
}
/no-preview.h
${
srcdir
}
/queries.h
${
srcdir
}
/structures.h
${
srcdir
}
/telegram.h
${
srcdir
}
/tree.h
${
srcdir
}
/config.h
${
srcdir
}
/binlog.h
INCLUDE
=
-I
.
-I
${
srcdir
}
CC
=
gcc
OBJECTS
=
main.o loop.o interface.o net.o mtproto-common.o mtproto-client.o queries.o structures.o binlog.o
.SUFFIXES
:
.SUFFIXES
:
.c .h .o
all
:
telegram
${OBJECTS}
:
${HEADERS}
telegram
:
${OBJECTS}
${
CC
}
${
OBJECTS
}
${
LINK_FLAGS
}
-o
$@
.c.o
:
${
CC
}
${
COMPILE_FLAGS
}
${
INCLUDE
}
-c
$<
-o
$@
clean
:
rm
-rf
*
.o telegram
>
/dev/null
||
echo
"all clean"
Makefile.in
View file @
29ed574e
...
@@ -7,7 +7,7 @@ DEFS=@DEFS@
...
@@ -7,7 +7,7 @@ DEFS=@DEFS@
COMPILE_FLAGS
=
${
CFLAGS
}
${
CPPFLAGS
}
${
DEFS
}
-Wall
-Wextra
-Werror
-Wno-deprecated
-fno-strict-aliasing
-fno-omit-frame-pointer
-ggdb
COMPILE_FLAGS
=
${
CFLAGS
}
${
CPPFLAGS
}
${
DEFS
}
-Wall
-Wextra
-Werror
-Wno-deprecated
-fno-strict-aliasing
-fno-omit-frame-pointer
-ggdb
EXTRA_LIBS
=
@EXTRA_LIBS@
EXTRA_LIBS
=
@EXTRA_LIBS@
LOCAL_LDFLAGS
=
-lm
-lcrypto
-lz
-lssl
-rdynamic
-ggdb
${
EXTRA_LIBS
}
LOCAL_LDFLAGS
=
-lm
-lcrypto
-lz
-lssl
-rdynamic
-ggdb
-lconfig
-lreadline
-lexecinfo
${
EXTRA_LIBS
}
LINK_FLAGS
=
${
LDFLAGS
}
${
LOCAL_LDFLAGS
}
LINK_FLAGS
=
${
LDFLAGS
}
${
LOCAL_LDFLAGS
}
HEADERS
=
${
srcdir
}
/constants.h
${
srcdir
}
/include.h
${
srcdir
}
/interface.h
${
srcdir
}
/LICENSE.h
${
srcdir
}
/loop.h
${
srcdir
}
/mtproto-client.h
${
srcdir
}
/mtproto-common.h
${
srcdir
}
/net.h
${
srcdir
}
/no-preview.h
${
srcdir
}
/queries.h
${
srcdir
}
/structures.h
${
srcdir
}
/telegram.h
${
srcdir
}
/tree.h
${
srcdir
}
/config.h
${
srcdir
}
/binlog.h
HEADERS
=
${
srcdir
}
/constants.h
${
srcdir
}
/include.h
${
srcdir
}
/interface.h
${
srcdir
}
/LICENSE.h
${
srcdir
}
/loop.h
${
srcdir
}
/mtproto-client.h
${
srcdir
}
/mtproto-common.h
${
srcdir
}
/net.h
${
srcdir
}
/no-preview.h
${
srcdir
}
/queries.h
${
srcdir
}
/structures.h
${
srcdir
}
/telegram.h
${
srcdir
}
/tree.h
${
srcdir
}
/config.h
${
srcdir
}
/binlog.h
...
@@ -31,5 +31,5 @@ telegram: ${OBJECTS}
...
@@ -31,5 +31,5 @@ telegram: ${OBJECTS}
clean
:
clean
:
rm
-rf
*
.o telegram
>
/dev/null
||
echo
"all clean"
rm
-rf
*
.o telegram
config.log config.status
>
/dev/null
||
echo
"all clean"
README.md
View file @
29ed574e
...
@@ -39,6 +39,18 @@ The client depends on [readline library](http://cnswww.cns.cwru.edu/php/chet/rea
...
@@ -39,6 +39,18 @@ The client depends on [readline library](http://cnswww.cns.cwru.edu/php/chet/rea
Thanks to
[
@jfontan
](
https://github.com/vysheng/tg/issues/3#issuecomment-28293731
)
for this solution.
Thanks to
[
@jfontan
](
https://github.com/vysheng/tg/issues/3#issuecomment-28293731
)
for this solution.
#### FreeBSD
Install these ports:
*
devel/libconfig
*
devel/libexecinfo
Then build:
$ env CC=clang CFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib ./configure
$ make
#### Other UNIX
#### Other UNIX
If you manage to launch it on other UNIX, please let me know.
If you manage to launch it on other UNIX, please let me know.
...
...
config.h
deleted
100644 → 0
View file @
41fc7c22
/* config.h. Generated from config.h.in by configure. */
/* config.h.in. Generated from configure.ac by autoheader. */
/* enable libconfig */
#define ENABLE_LIBCONFIG 1
/* Define to 1 if you have the <fcntl.h> header file. */
#define HAVE_FCNTL_H 1
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the `crypto' library (-lcrypto). */
#define HAVE_LIBCRYPTO 1
/* Define to 1 if you have the `edit' library (-ledit). */
/* #undef HAVE_LIBEDIT */
/* Define to 1 if you have the `m' library (-lm). */
#define HAVE_LIBM 1
/* Define to 1 if your system has a GNU libc compatible `malloc' function, and
to 0 otherwise. */
#define HAVE_MALLOC 1
/* Define to 1 if you have the <malloc.h> header file. */
#define HAVE_MALLOC_H 1
/* Define to 1 if you have the <memory.h> header file. */
#define HAVE_MEMORY_H 1
/* Define to 1 if you have the `memset' function. */
#define HAVE_MEMSET 1
/* Define to 1 if your system has a GNU libc compatible `realloc' function,
and to 0 otherwise. */
#define HAVE_REALLOC 1
/* Define to 1 if you have the `select' function. */
#define HAVE_SELECT 1
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the `strdup' function. */
#define HAVE_STRDUP 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the `strndup' function. */
#define HAVE_STRNDUP 1
/* Define to 1 if you have the <sys/socket.h> header file. */
#define HAVE_SYS_SOCKET_H 1
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT ""
/* Define to the full name of this package. */
#define PACKAGE_NAME "telegram"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "telegram 0.1"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "telegram"
/* Define to the home page for this package. */
#define PACKAGE_URL ""
/* Define to the version of this package. */
#define PACKAGE_VERSION "0.1"
/* Use libedit */
/* #undef READLINE_EDIT */
/* Use gnu libreadline */
#define READLINE_GNU 1
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Define to rpl_malloc if the replacement function should be used. */
/* #undef malloc */
/* Define to rpl_realloc if the replacement function should be used. */
/* #undef realloc */
/* Define to `unsigned int' if <sys/types.h> does not define. */
/* #undef size_t */
loop.c
View file @
29ed574e
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
*/
*/
#define READLINE_CALLBACKS
#define READLINE_CALLBACKS
#include "config.h"
#include "config.h"
#define _GNU_SOURCE
#include <assert.h>
#include <assert.h>
#include <stdio.h>
#include <stdio.h>
...
...
mtproto-client.c
View file @
29ed574e
...
@@ -26,6 +26,7 @@
...
@@ -26,6 +26,7 @@
#include <signal.h>
#include <signal.h>
#include <unistd.h>
#include <unistd.h>
#include <fcntl.h>
#include <fcntl.h>
#include <sys/endian.h>
#include <sys/types.h>
#include <sys/types.h>
#include <aio.h>
#include <aio.h>
#include <netdb.h>
#include <netdb.h>
...
@@ -34,6 +35,7 @@
...
@@ -34,6 +35,7 @@
#include <openssl/pem.h>
#include <openssl/pem.h>
#include <openssl/sha.h>
#include <openssl/sha.h>
#include <sys/socket.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <netinet/tcp.h>
#include <poll.h>
#include <poll.h>
#include <zlib.h>
#include <zlib.h>
...
@@ -46,6 +48,10 @@
...
@@ -46,6 +48,10 @@
#include "structures.h"
#include "structures.h"
#include "binlog.h"
#include "binlog.h"
#if defined(__FreeBSD__)
#define __builtin_bswap32(x) bswap32(x)
#endif
#define sha1 SHA1
#define sha1 SHA1
#include "mtproto-common.h"
#include "mtproto-common.h"
...
@@ -1585,7 +1591,7 @@ int rpc_execute (struct connection *c, int op, int len) {
...
@@ -1585,7 +1591,7 @@ int rpc_execute (struct connection *c, int op, int len) {
logprintf
(
"have %d Response bytes
\n
"
,
Response_len
);
logprintf
(
"have %d Response bytes
\n
"
,
Response_len
);
}
}
#if
ndef __MACH__
#if
!defined(__MACH__) && !defined(__FreeBSD__)
setsockopt
(
c
->
fd
,
IPPROTO_TCP
,
TCP_QUICKACK
,
(
int
[]){
0
},
4
);
setsockopt
(
c
->
fd
,
IPPROTO_TCP
,
TCP_QUICKACK
,
(
int
[]){
0
},
4
);
#endif
#endif
int
o
=
c_state
;
int
o
=
c_state
;
...
@@ -1593,19 +1599,19 @@ int rpc_execute (struct connection *c, int op, int len) {
...
@@ -1593,19 +1599,19 @@ int rpc_execute (struct connection *c, int op, int len) {
switch
(
o
)
{
switch
(
o
)
{
case
st_reqpq_sent
:
case
st_reqpq_sent
:
process_respq_answer
(
c
,
Response
/* + 8*/
,
Response_len
/* - 12*/
);
process_respq_answer
(
c
,
Response
/* + 8*/
,
Response_len
/* - 12*/
);
#if
ndef __MACH__
#if
!defined(__MACH__) && !defined(__FreeBSD__)
setsockopt
(
c
->
fd
,
IPPROTO_TCP
,
TCP_QUICKACK
,
(
int
[]){
0
},
4
);
setsockopt
(
c
->
fd
,
IPPROTO_TCP
,
TCP_QUICKACK
,
(
int
[]){
0
},
4
);
#endif
#endif
return
0
;
return
0
;
case
st_reqdh_sent
:
case
st_reqdh_sent
:
process_dh_answer
(
c
,
Response
/* + 8*/
,
Response_len
/* - 12*/
);
process_dh_answer
(
c
,
Response
/* + 8*/
,
Response_len
/* - 12*/
);
#if
ndef __MACH__
#if
!defined(__MACH__) && !defined(__FreeBSD__)
setsockopt
(
c
->
fd
,
IPPROTO_TCP
,
TCP_QUICKACK
,
(
int
[]){
0
},
4
);
setsockopt
(
c
->
fd
,
IPPROTO_TCP
,
TCP_QUICKACK
,
(
int
[]){
0
},
4
);
#endif
#endif
return
0
;
return
0
;
case
st_client_dh_sent
:
case
st_client_dh_sent
:
process_auth_complete
(
c
,
Response
/* + 8*/
,
Response_len
/* - 12*/
);
process_auth_complete
(
c
,
Response
/* + 8*/
,
Response_len
/* - 12*/
);
#if
ndef __MACH__
#if
!defined(__MACH__) && !defined(__FreeBSD__)
setsockopt
(
c
->
fd
,
IPPROTO_TCP
,
TCP_QUICKACK
,
(
int
[]){
0
},
4
);
setsockopt
(
c
->
fd
,
IPPROTO_TCP
,
TCP_QUICKACK
,
(
int
[]){
0
},
4
);
#endif
#endif
return
0
;
return
0
;
...
@@ -1615,7 +1621,7 @@ int rpc_execute (struct connection *c, int op, int len) {
...
@@ -1615,7 +1621,7 @@ int rpc_execute (struct connection *c, int op, int len) {
}
else
{
}
else
{
process_rpc_message
(
c
,
(
void
*
)(
Response
/* + 8*/
),
Response_len
/* - 12*/
);
process_rpc_message
(
c
,
(
void
*
)(
Response
/* + 8*/
),
Response_len
/* - 12*/
);
}
}
#if
ndef __MACH__
#if
!defined(__MACH__) && !defined(__FreeBSD__)
setsockopt
(
c
->
fd
,
IPPROTO_TCP
,
TCP_QUICKACK
,
(
int
[]){
0
},
4
);
setsockopt
(
c
->
fd
,
IPPROTO_TCP
,
TCP_QUICKACK
,
(
int
[]){
0
},
4
);
#endif
#endif
return
0
;
return
0
;
...
@@ -1643,7 +1649,7 @@ int tc_becomes_ready (struct connection *c) {
...
@@ -1643,7 +1649,7 @@ int tc_becomes_ready (struct connection *c) {
assert
(
write_out
(
c
,
&
byte
,
1
)
==
1
);
assert
(
write_out
(
c
,
&
byte
,
1
)
==
1
);
flush_out
(
c
);
flush_out
(
c
);
#if
ndef __MACH__
#if
!defined(__MACH__) && !defined(__FreeBSD__)
setsockopt
(
c
->
fd
,
IPPROTO_TCP
,
TCP_QUICKACK
,
(
int
[]){
0
},
4
);
setsockopt
(
c
->
fd
,
IPPROTO_TCP
,
TCP_QUICKACK
,
(
int
[]){
0
},
4
);
#endif
#endif
int
o
=
c_state
;
int
o
=
c_state
;
...
...
net.c
View file @
29ed574e
...
@@ -21,8 +21,11 @@
...
@@ -21,8 +21,11 @@
#include <stdlib.h>
#include <stdlib.h>
#include <assert.h>
#include <assert.h>
#include <netdb.h>
#include <netdb.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
#include <netinet/tcp.h>
#include <sys/fcntl.h>
#include <sys/fcntl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <errno.h>
#include <errno.h>
#include <stdio.h>
#include <stdio.h>
#include <unistd.h>
#include <unistd.h>
...
@@ -37,7 +40,7 @@
...
@@ -37,7 +40,7 @@
#include "tree.h"
#include "tree.h"
#include "interface.h"
#include "interface.h"
#if
def __MACH__
#if
defined(__MACH__) || defined(__FreeBSD__)
#define POLLRDHUP 0
#define POLLRDHUP 0
#endif
#endif
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment