├── debian ├── compat ├── source │ └── format ├── rules ├── changelog ├── tcpview.install ├── control └── copyright ├── translations ├── language_cs.qm ├── language_de.qm ├── language_en.qm ├── language_es.qm ├── language_fr.qm ├── language_ja.qm ├── language_pl.qm ├── language_ru.qm ├── language_sl.qm ├── language_zh_CN.qm ├── language_zh_TW.qm ├── language_en.ts ├── language_ru.ts ├── language_cs.ts └── language_de.ts ├── ISSUE_TEMPLATE.md ├── .gitignore ├── .travis.yml ├── data ├── tcpview.desktop ├── tcpview.svg └── tcpviewU.svg ├── tcpview.qrc ├── source ├── cusername.h ├── cstylehelperex.h ├── ccfontsize.h ├── cusername.cpp ├── cportservicenames.h ├── defined.h ├── buffer.h ├── clanguage.h ├── tableheadercaption.h ├── cfilesavewrapper.h ├── ccustomproxymodel.h ├── cconnectionstree.h ├── cstylehelperex.cpp ├── connectionstatehelper.h ├── cportservicenames.cpp ├── ccfontsize.cpp ├── configdialog.h ├── buffer.cpp ├── rootmodule.h ├── ccustomproxymodel.cpp ├── clanguage.cpp ├── cfilesavewrapper.cpp ├── connectionstatehelper.cpp ├── datasource.h ├── cconnectionstree.cpp ├── datasource.cpp ├── rootmodule.cpp └── configdialog.cpp ├── appveyor.yml ├── main.cpp ├── mainwindow.h ├── README.md ├── tcpview.pro └── mainwindow.ui /debian/compat: -------------------------------------------------------------------------------- 1 | 9 2 | -------------------------------------------------------------------------------- /debian/source/format: -------------------------------------------------------------------------------- 1 | 3.0 (quilt) 2 | -------------------------------------------------------------------------------- /translations/language_cs.qm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipmunk-sm/tcpview/HEAD/translations/language_cs.qm -------------------------------------------------------------------------------- /translations/language_de.qm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipmunk-sm/tcpview/HEAD/translations/language_de.qm -------------------------------------------------------------------------------- /translations/language_en.qm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipmunk-sm/tcpview/HEAD/translations/language_en.qm -------------------------------------------------------------------------------- /translations/language_es.qm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipmunk-sm/tcpview/HEAD/translations/language_es.qm -------------------------------------------------------------------------------- /translations/language_fr.qm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipmunk-sm/tcpview/HEAD/translations/language_fr.qm -------------------------------------------------------------------------------- /translations/language_ja.qm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipmunk-sm/tcpview/HEAD/translations/language_ja.qm -------------------------------------------------------------------------------- /translations/language_pl.qm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipmunk-sm/tcpview/HEAD/translations/language_pl.qm -------------------------------------------------------------------------------- /translations/language_ru.qm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipmunk-sm/tcpview/HEAD/translations/language_ru.qm -------------------------------------------------------------------------------- /translations/language_sl.qm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipmunk-sm/tcpview/HEAD/translations/language_sl.qm -------------------------------------------------------------------------------- /debian/rules: -------------------------------------------------------------------------------- 1 | #!/usr/bin/make -f 2 | 3 | export DH_VERBOSE = 1 4 | export QT_SELECT=5 5 | 6 | %: 7 | dh $@ 8 | 9 | -------------------------------------------------------------------------------- /translations/language_zh_CN.qm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipmunk-sm/tcpview/HEAD/translations/language_zh_CN.qm -------------------------------------------------------------------------------- /translations/language_zh_TW.qm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/chipmunk-sm/tcpview/HEAD/translations/language_zh_TW.qm -------------------------------------------------------------------------------- /debian/changelog: -------------------------------------------------------------------------------- 1 | tcpview (3.4.0) stable; urgency=medium 2 | 3 | * New release 4 | 5 | -- chipmunk.sm Sat, 17 Apr 2021 10:00:00 +0000 6 | -------------------------------------------------------------------------------- /debian/tcpview.install: -------------------------------------------------------------------------------- 1 | tcpview usr/bin 2 | data/tcpview.desktop usr/share/applications 3 | data/tcpview.svg usr/share/icons/hicolor/scalable/apps 4 | data/tcpviewU.svg usr/share/icons/hicolor/scalable/apps 5 | 6 | -------------------------------------------------------------------------------- /ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 2 | * Linux distro. Type the following at the command line: 3 | ``` 4 | $ uname -m && cat /etc/*release 5 | ``` 6 | * Where did you get the program: PPA, or build from source. 7 | * Qt version (optional) 8 | * Expected & Actual results 9 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | build/* 2 | tcpview.pro.user 3 | *.autosave 4 | /translations/*.txt 5 | /.vs 6 | /debug 7 | /release 8 | /.qmake.stash 9 | /tcpview.qtvscr 10 | /tcpview.sln 11 | /tcpview.vcxproj 12 | /tcpview.vcxproj.filters 13 | /tcpview.vcxproj.user 14 | /ui_mainwindow.h 15 | -------------------------------------------------------------------------------- /debian/control: -------------------------------------------------------------------------------- 1 | Source: tcpview 2 | Section: utils 3 | Priority: optional 4 | Maintainer: chipmunk.sm 5 | Build-Depends: debhelper (>=9), 6 | uuid-dev, 7 | qtbase5-dev 8 | Standards-Version: 3.9.8 9 | Homepage: https://github.com/chipmunk-sm/tcpview 10 | 11 | Package: tcpview 12 | Architecture: any 13 | Depends: ${shlibs:Depends}, ${misc:Depends} 14 | Description: TcpView For Linux - Graphical Network Connections Viewer For Linux 15 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | 3 | jobs: 4 | include: 5 | - name: "Xenial.16.04" 6 | dist: xenial 7 | os: linux 8 | env: BUILD_FLAG=-qt=qt5 9 | 10 | - name: "Bionic.18.04" 11 | dist: bionic 12 | os: linux 13 | env: BUILD_FLAG=-qt=qt5 14 | 15 | - name: "Focal.20.04" 16 | dist: focal 17 | os: linux 18 | 19 | before_install: 20 | - sudo apt-get update; 21 | - sudo apt-get install -y qtbase5-dev qttools5-dev-tools; 22 | 23 | script: 24 | - qmake $BUILD_FLAG 25 | - make -j$(nproc) 26 | -------------------------------------------------------------------------------- /data/tcpview.desktop: -------------------------------------------------------------------------------- 1 | [Desktop Entry] 2 | Categories=Utility; 3 | Comment[en_US]=Graphical Network Connections Viewer 4 | Comment=Graphical Network Connections Viewer 5 | Exec=tcpview 6 | GenericName[en_US]=Network Connections Viewer 7 | GenericName=Network Connections Viewer 8 | Icon=tcpviewU 9 | MimeType= 10 | Name[en_US]=TcpView For Linux 11 | Name=TcpView For Linux 12 | Path= 13 | StartupNotify=true 14 | Terminal=false 15 | TerminalOptions= 16 | Type=Application 17 | X-DBUS-ServiceName= 18 | X-DBUS-StartupType= 19 | X-KDE-SubstituteUID=false 20 | X-KDE-Username= 21 | -------------------------------------------------------------------------------- /tcpview.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | data/tcpview.svg 4 | data/tcpviewU.svg 5 | translations/language_en.qm 6 | translations/language_ru.qm 7 | translations/language_zh_TW.qm 8 | translations/language_zh_CN.qm 9 | translations/language_sl.qm 10 | translations/language_pl.qm 11 | translations/language_ja.qm 12 | translations/language_fr.qm 13 | translations/language_de.qm 14 | translations/language_cs.qm 15 | 16 | 17 | -------------------------------------------------------------------------------- /source/cusername.h: -------------------------------------------------------------------------------- 1 | /* This file is part of "TcpView For Linux" - network connections viewer for Linux 2 | * Copyright (C) 2021 chipmunk-sm 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef CUSERNAME_H 19 | #define CUSERNAME_H 20 | 21 | #include 22 | 23 | class CUserName 24 | { 25 | public: 26 | static QString GetUserNameString(__uid_t euid, bool bErrorUser); 27 | }; 28 | 29 | #endif // CUSERNAME_H 30 | -------------------------------------------------------------------------------- /source/cstylehelperex.h: -------------------------------------------------------------------------------- 1 | /* This file is part of "TcpView For Linux" - network connections viewer for Linux 2 | * Copyright (C) 2021 chipmunk-sm 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef CSTYLEHELPEREX_H 19 | #define CSTYLEHELPEREX_H 20 | 21 | class QWidget; 22 | 23 | class CStyleHelperEx 24 | { 25 | public: 26 | static double SetStyle(double size, QWidget *obj); 27 | }; 28 | 29 | #endif // CSTYLEHELPEREX_H 30 | -------------------------------------------------------------------------------- /source/ccfontsize.h: -------------------------------------------------------------------------------- 1 | /* This file is part of "TcpView For Linux" - network connections viewer for Linux 2 | * Copyright (C) 2021 chipmunk-sm 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef CCFONTSIZE_H 19 | #define CCFONTSIZE_H 20 | 21 | class QWidget; 22 | 23 | class CCFontSize 24 | { 25 | public: 26 | static double changeFontSize(double change, QWidget* pObj); 27 | private: 28 | static const char* GetConfigName(); 29 | }; 30 | 31 | #endif // CCFONTSIZE_H 32 | -------------------------------------------------------------------------------- /source/cusername.cpp: -------------------------------------------------------------------------------- 1 | /* This file is part of "TcpView For Linux" - network connections viewer for Linux 2 | * Copyright (C) 2021 chipmunk-sm 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include "cusername.h" 19 | 20 | #include 21 | 22 | QString CUserName::GetUserNameString(__uid_t euid, bool bErrorUser) 23 | { 24 | if(bErrorUser) 25 | return QString("- error userid -"); 26 | 27 | struct passwd *ptr = getpwuid(euid); 28 | if(ptr) 29 | return QString(ptr->pw_name); 30 | 31 | return QString::number(euid); 32 | } 33 | -------------------------------------------------------------------------------- /source/cportservicenames.h: -------------------------------------------------------------------------------- 1 | /* This file is part of "TcpView For Linux" - network connections viewer for Linux 2 | * Copyright (C) 2021 chipmunk-sm 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef CPORTSERVICENAMES_H 19 | #define CPORTSERVICENAMES_H 20 | 21 | #include 22 | #include 23 | 24 | class CPortServiceNames 25 | { 26 | public: 27 | CPortServiceNames(); 28 | void getServiceName(int port, char *buff, size_t buffLength, bool IsTcp); 29 | private: 30 | std::map m_portTcp; 31 | std::map m_portUdp; 32 | }; 33 | 34 | #endif // CPORTSERVICENAMES_H 35 | -------------------------------------------------------------------------------- /source/defined.h: -------------------------------------------------------------------------------- 1 | /* This file is part of "TcpView For Linux" - network connections viewer for Linux 2 | * Copyright (C) 2021 chipmunk-sm 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef DEFINED_H 19 | #define DEFINED_H 20 | 21 | #define PROC_NET_TCP "/proc/net/tcp" 22 | #define PROC_NET_UDP "/proc/net/udp" 23 | #define PROC_NET_TCP6 "/proc/net/tcp6" 24 | #define PROC_NET_UDP6 "/proc/net/udp6" 25 | #define PROC_NET_RAW "/proc/net/raw" 26 | #define PROC_NET_RAW6 "/proc/net/raw6" 27 | 28 | #define PROC_PATH "/proc" 29 | #define PROC_PATH_FD "/proc/%d/fd" 30 | #define PROC_PATH_FD2 "/proc/%d/fd/%s" 31 | #define PROC_PATH_CMD "/proc/%d/cmdline" 32 | 33 | #endif // DEFINED_H 34 | -------------------------------------------------------------------------------- /source/buffer.h: -------------------------------------------------------------------------------- 1 | /* This file is part of "TcpView For Linux" - network connections viewer for Linux 2 | * Copyright (C) 2021 chipmunk-sm 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef CBUFFER_H 19 | #define CBUFFER_H 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #define CSTREAMBUFFER_MAX_100MB 1024 * 1024 * 100 26 | #define CSTREAMBUFFER_MAX CSTREAMBUFFER_MAX_100MB 27 | 28 | #define CSTREAMBUFFER_MIN_INC_SIZE_BYTES 1024 29 | 30 | class CBuffer 31 | { 32 | public: 33 | CBuffer(); 34 | ~CBuffer(); 35 | void Clear(); 36 | uint8_t* GetBufferPtr(size_t lBufferSize); 37 | size_t GetBufferSize(); 38 | 39 | private: 40 | uint8_t* m_pBuffer; 41 | size_t m_bufferSize; 42 | std::string m_error; 43 | }; 44 | 45 | #endif // CBUFFER_H 46 | -------------------------------------------------------------------------------- /debian/copyright: -------------------------------------------------------------------------------- 1 | Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ 2 | Upstream-Name: TcpView For Linux 3 | Source: https://github.com/chipmunk-sm/tcpview 4 | 5 | Files: * 6 | Copyright: 2021 chipmunk-sm 7 | License: GPL-3.0+ 8 | 9 | Files: debian/* 10 | Copyright: 2021 chipmunk-sm 11 | License: GPL-3.0+ 12 | 13 | License: GPL-3.0+ 14 | This program is free software: you can redistribute it and/or modify 15 | it under the terms of the GNU General Public License as published by 16 | the Free Software Foundation, either version 3 of the License, or 17 | (at your option) any later version. 18 | . 19 | This package is distributed in the hope that it will be useful, 20 | but WITHOUT ANY WARRANTY; without even the implied warranty of 21 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 22 | GNU General Public License for more details. 23 | . 24 | You should have received a copy of the GNU General Public License 25 | along with this program. If not, see . 26 | . 27 | On Debian systems, the complete text of the GNU General 28 | Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". 29 | 30 | # Please also look if there are files or directories which have a 31 | # different copyright/license attached and list them here. 32 | # Please avoid picking licenses with terms that are more restrictive than the 33 | # packaged work, as it may make Debian's contributions unacceptable upstream. 34 | -------------------------------------------------------------------------------- /appveyor.yml: -------------------------------------------------------------------------------- 1 | version: 3.0.{build}.{branch} 2 | 3 | environment: 4 | matrix: 5 | 6 | #Ubuntu2204 - Ubuntu 22.04 (Jammy Jellyfish) 7 | - job_name: "ubuntu.22.04" 8 | APPVEYOR_BUILD_WORKER_IMAGE: ubuntu2204 9 | QT_VERSION: qt5 10 | 11 | #Ubuntu2004 - Ubuntu 20.04 (Focal Fossa) 12 | - job_name: "ubuntu.20.04" 13 | APPVEYOR_BUILD_WORKER_IMAGE: ubuntu2004 14 | QT_VERSION: qt5 15 | 16 | #Ubuntu1804 - Ubuntu 18.04 (Bionic Beaver) 17 | - job_name: "Ubuntu.18.04" 18 | APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu1804 19 | QT_VERSION: qt5 20 | 21 | #Ubuntu1604 - Ubuntu 16.04 (Xenial Xerus) 22 | - job_name: "Ubuntu.16.04" 23 | APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu1604 24 | QT_VERSION: qt5 25 | 26 | install: 27 | - sh: if [ "$APPVEYOR_BUILD_WORKER_IMAGE" = "Ubuntu1804" ] || [ "$APPVEYOR_BUILD_WORKER_IMAGE" = "Ubuntu1604" ]; then sudo rm -f /etc/apt/sources.list.d/google-chrome.list; fi 28 | - sh: sudo apt-get update 29 | - sh: | 30 | if [ "$QT_VERSION" = "qt6" ]; then 31 | sudo apt-get install -y qt6-base-dev uuid-dev 32 | else 33 | sudo apt-get install -y qtbase5-dev uuid-dev 34 | fi 35 | 36 | build_script: 37 | - sh: set -e 38 | - sh: | 39 | if [ "$QT_VERSION" = "qt6" ]; then 40 | export QT_SELECT=qt6 41 | else 42 | export QT_SELECT=qt5 43 | fi 44 | - sh: qmake --version 45 | - sh: qmake -qt=$QT_VERSION 46 | - sh: make -j$(nproc) 47 | -------------------------------------------------------------------------------- /source/clanguage.h: -------------------------------------------------------------------------------- 1 | /* This file is part of "TcpView For Linux" - network connections viewer for Linux 2 | * Copyright (C) 2021 chipmunk-sm 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef CLANGUAGE_H 19 | #define CLANGUAGE_H 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | class CLanguage 29 | { 30 | public: 31 | CLanguage(); 32 | void SetLang(const QString &langName); 33 | void SetLangByLocale(); 34 | bool SetLangByLocale(QString localeName); 35 | const QStringList GetListLangNames(); 36 | void LoadTranslations(const QDir &dir); 37 | QString ExtractLanguageName(const QString &fileName); 38 | 39 | private: 40 | QStringList m_langNames; 41 | QMap m_langList; 42 | QTranslator m_translator; 43 | }; 44 | 45 | #endif // CLANGUAGE_H 46 | -------------------------------------------------------------------------------- /source/tableheadercaption.h: -------------------------------------------------------------------------------- 1 | /* This file is part of "TcpView For Linux" - network connections viewer for Linux 2 | * Copyright (C) 2021 chipmunk-sm 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef TABLEHEADERCAPTION_H 19 | #define TABLEHEADERCAPTION_H 20 | 21 | #include 22 | 23 | class TableHeaderCaption 24 | { 25 | public: 26 | TableHeaderCaption(const QString &caption, const QString &captionSample, const QString &captionToolTip) 27 | { 28 | m_caption = caption; 29 | m_captionSample = captionSample; 30 | m_captionToolTip = captionToolTip; 31 | } 32 | 33 | QString caption() const { return m_caption; } 34 | QString captionSample() const { return m_captionSample; } 35 | QString captionToolTip() const { return m_captionToolTip; } 36 | 37 | private: 38 | QString m_caption; 39 | QString m_captionSample; 40 | QString m_captionToolTip; 41 | }; 42 | 43 | #endif // TABLEHEADERCAPTION_H 44 | -------------------------------------------------------------------------------- /source/cfilesavewrapper.h: -------------------------------------------------------------------------------- 1 | /* This file is part of "TcpView For Linux" - network connections viewer for Linux 2 | * Copyright (C) 2021 chipmunk-sm 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef CFILESAVEWRAPPER_H 19 | #define CFILESAVEWRAPPER_H 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | class CFileSaveWrapper 28 | { 29 | public: 30 | CFileSaveWrapper(); 31 | ~CFileSaveWrapper(); 32 | void Open(const QString fileName, const QString fileType, QWidget *parent); 33 | void Close(); 34 | void ElemStart(const QString Val); 35 | void ElemVal(const QString Val); 36 | void ElemEnd(const QString Val); 37 | 38 | private: 39 | QWidget *m_parent; 40 | QFile *m_pQFile; 41 | QXmlStreamWriter *m_pQXmlStreamWriter; 42 | QTextStream *m_pQTextStream; 43 | QVector m_tag; 44 | }; 45 | 46 | #endif // CFILESAVEWRAPPER_H 47 | -------------------------------------------------------------------------------- /data/tcpview.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | image/svg+xml 7 | 8 | 9 | 10 | 11 | Copyright (C) 2021 chipmunk.sm <dannico@linuxmail.org> 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- 1 | /* This file is part of "TcpView For Linux" - network connections viewer for Linux 2 | * Copyright (C) 2021 chipmunk-sm 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include "mainwindow.h" 19 | #include 20 | #include 21 | #include "source/rootmodule.h" 22 | #include "source/clanguage.h" 23 | 24 | int main(int argc, char *argv[]) 25 | { 26 | 27 | auto runRootModule = (argc == 3 && argv[1] != nullptr && strstr(argv[1], "rootmodule") != nullptr); 28 | if(runRootModule) 29 | { 30 | auto root = std::make_shared(getpid(), argv[2]); 31 | if(root->isAbort()) 32 | return -1; 33 | 34 | root->RunServer(); 35 | return 0x0; 36 | } 37 | 38 | Q_INIT_RESOURCE(tcpview); 39 | 40 | QApplication app(argc, argv); 41 | 42 | QCoreApplication::setOrganizationDomain(""); 43 | QCoreApplication::setOrganizationName("chipmunk-sm"); 44 | QCoreApplication::setApplicationName("tcpview"); 45 | QCoreApplication::setApplicationVersion("3.0 beta"); 46 | 47 | CLanguage m_lang; 48 | m_lang.SetLangByLocale(); 49 | 50 | MainWindow w; 51 | w.show(); 52 | 53 | return app.exec(); 54 | 55 | } 56 | -------------------------------------------------------------------------------- /source/ccustomproxymodel.h: -------------------------------------------------------------------------------- 1 | /* This file is part of "TcpView For Linux" - network connections viewer for Linux 2 | * Copyright (C) 2021 chipmunk-sm 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include "connectionstatehelper.h" 19 | #include 20 | #include 21 | 22 | #ifndef CCUSTOMPROXYMODEL_H 23 | #define CCUSTOMPROXYMODEL_H 24 | 25 | typedef struct ColorItem 26 | { 27 | QColor Foreground; 28 | QColor Background; 29 | }ColorItem; 30 | 31 | typedef enum DataTyp{ 32 | DataTyp_TypId = Qt::UserRole + 50, 33 | DataTyp_TypState = Qt::UserRole + 51 34 | }DataTyp; 35 | 36 | class CCustomProxyModel : public QSortFilterProxyModel 37 | { 38 | Q_OBJECT 39 | public: 40 | CCustomProxyModel(QObject *parent = nullptr); 41 | void setFilterRegExpEx(const QString &val); 42 | void updateColorMap(); 43 | protected: 44 | bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const Q_DECL_OVERRIDE; 45 | QRegExp m_QRegExp; 46 | virtual QVariant data(const QModelIndex &index, int role) const override; 47 | std::atomic m_updateColor = ATOMIC_FLAG_INIT; 48 | mutable std::map m_color; 49 | }; 50 | 51 | #endif // CCUSTOMPROXYMODEL_H 52 | -------------------------------------------------------------------------------- /source/cconnectionstree.h: -------------------------------------------------------------------------------- 1 | /* This file is part of "TcpView For Linux" - network connections viewer for Linux 2 | * Copyright (C) 2021 chipmunk-sm 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef CCONNECTIONSTREE_H 19 | #define CCONNECTIONSTREE_H 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include "datasource.h" 26 | #include "tableheadercaption.h" 27 | #include "ccustomproxymodel.h" 28 | #include "connectionstatehelper.h" 29 | 30 | class CConnectionsTree 31 | { 32 | public: 33 | CConnectionsTree(); 34 | ~CConnectionsTree(); 35 | void InitConnectonsTree(QTreeView *connView); 36 | void UpdateIncludeFilter(const QString &value); 37 | void UpdateData(SocketInfo * dataSource, bool disableCleanup); 38 | void Save(QWidget *parent); 39 | 40 | private: 41 | QMap m_caption; 42 | QMap m_protocol; 43 | CCustomProxyModel *m_pProxyModel; 44 | ConnectionStateHelper m_ConnectionStateHelper; 45 | void PrepareTableCaptionString(); 46 | void PrepareTableProtocolString(); 47 | 48 | }; 49 | 50 | #endif // CCONNECTIONSTREE_H 51 | -------------------------------------------------------------------------------- /data/tcpviewU.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | image/svg+xml 6 | 7 | 8 | 9 | 10 | Copyright (C) 2021 chipmunk.sm <dannico@linuxmail.org> 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /source/cstylehelperex.cpp: -------------------------------------------------------------------------------- 1 | /* This file is part of "TcpView For Linux" - network connections viewer for Linux 2 | * Copyright (C) 2021 chipmunk-sm 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include "cstylehelperex.h" 19 | 20 | #include 21 | #include 22 | #include 23 | 24 | double CStyleHelperEx::SetStyle(double size, QWidget *obj) { 25 | 26 | 27 | QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName()); 28 | auto valColor = settings.value("tree/color"); 29 | 30 | // QFontMetrics fm(fontX); 31 | 32 | auto valSize = QString::number(size); 33 | auto valSize1 = QString::number(size / 4); 34 | 35 | auto style = "QPushButton { icon-size: " + valSize + "px; padding-left: " + valSize + "px; padding-right: " + valSize + "px; padding-top: " + valSize1 + "px; padding-bottom: " + valSize1 + "px; }" 36 | "QHeaderView::section { padding-left: " + valSize + "px; padding-right: " + valSize + "px; padding-top: " + valSize1 + "px; padding-bottom: " + valSize1 + "px }"; 37 | 38 | if (valColor.isValid()) { 39 | style += "QTreeView { background: " + valColor.toString() + "; }"; 40 | } 41 | 42 | obj->setStyleSheet(style); 43 | 44 | return size; 45 | } 46 | -------------------------------------------------------------------------------- /source/connectionstatehelper.h: -------------------------------------------------------------------------------- 1 | /* This file is part of "TcpView For Linux" - network connections viewer for Linux 2 | * Copyright (C) 2021 chipmunk-sm 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "datasource.h" 23 | 24 | #ifndef CONNECTIONSTATEHELPER_H 25 | #define CONNECTIONSTATEHELPER_H 26 | 27 | class ConnectionStateItem 28 | { 29 | public: 30 | QString name; 31 | QColor foreground; 32 | QColor background; 33 | }; 34 | 35 | class ConnectionStateHelper 36 | { 37 | public: 38 | ConnectionStateHelper(); 39 | 40 | QString getStateName(eConnectionTcpState id); 41 | QColor getStateColor(eConnectionTcpState id, bool foreground); 42 | void saveColor(eConnectionTcpState id, const QColor & defColor, bool foreground); 43 | const std::map getArray() const; 44 | void updatetColor(bool reset); 45 | void setBwColor(); 46 | void setWbColor(); 47 | private: 48 | void initParameters(eConnectionTcpState id, QColor defColorForeground, QColor defColorBackground, const QString &name, bool reset); 49 | QString getKeyName(eConnectionTcpState id, bool foreground); 50 | 51 | std::map m_state; 52 | }; 53 | 54 | #endif // CONNECTIONSTATEHELPER_H 55 | -------------------------------------------------------------------------------- /source/cportservicenames.cpp: -------------------------------------------------------------------------------- 1 | /* This file is part of "TcpView For Linux" - network connections viewer for Linux 2 | * Copyright (C) 2021 chipmunk-sm 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include "cportservicenames.h" 19 | 20 | #include 21 | #include 22 | 23 | CPortServiceNames::CPortServiceNames() 24 | { 25 | // *Thread safety MT-Unsafe 26 | // 27 | struct servent *sentry; 28 | setservent(0); 29 | while ( (sentry = getservent()) != nullptr ) 30 | { 31 | if(std::strcmp(sentry->s_proto,"tcp") == 0) 32 | m_portTcp.insert(std::pair(ntohl(static_cast(sentry->s_port)), std::string(sentry->s_name))); 33 | else if(std::strcmp(sentry->s_proto,"udp") == 0) 34 | m_portUdp.insert(std::pair(ntohl(static_cast(sentry->s_port)), std::string(sentry->s_name))); 35 | } 36 | endservent(); 37 | 38 | } 39 | 40 | void CPortServiceNames::getServiceName(int port, char *buff, size_t buffLength, bool IsTcp) 41 | { 42 | 43 | auto pNames = IsTcp ? &m_portTcp : &m_portUdp; 44 | 45 | auto it = pNames->find(port); 46 | if (it == pNames->end()) 47 | std::snprintf(buff, buffLength, "%d", port); 48 | else 49 | std::snprintf(buff, buffLength, "%d (%s)", port, it->second.c_str()); 50 | } 51 | -------------------------------------------------------------------------------- /source/ccfontsize.cpp: -------------------------------------------------------------------------------- 1 | /* This file is part of "TcpView For Linux" - network connections viewer for Linux 2 | * Copyright (C) 2021 chipmunk-sm 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include "ccfontsize.h" 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | 25 | #include "cstylehelperex.h" 26 | 27 | double CCFontSize::changeFontSize(double change, QWidget* pObj) 28 | { 29 | 30 | auto fontX = QApplication::font(); 31 | 32 | const double pixSize = fontX.pixelSize(); 33 | const double pointSize = fontX.pointSizeF(); 34 | 35 | const double fontSize = pointSize > 0 ? pointSize : pixSize; 36 | 37 | QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName()); 38 | auto tmpSz = settings.value(GetConfigName(), fontSize).toDouble(); 39 | 40 | tmpSz += change; 41 | 42 | if (tmpSz < 5.0) 43 | tmpSz = 5.0; 44 | 45 | if (tmpSz > 100.0) 46 | tmpSz = 100.0; 47 | 48 | settings.setValue(GetConfigName(), tmpSz); 49 | 50 | if(pointSize > 0) 51 | fontX.setPointSizeF(tmpSz); 52 | else 53 | fontX.setPixelSize(static_cast(tmpSz)); 54 | 55 | QApplication::setFont(fontX); 56 | 57 | CStyleHelperEx::SetStyle(tmpSz, pObj); 58 | 59 | return tmpSz; 60 | } 61 | 62 | const char *CCFontSize::GetConfigName() 63 | { 64 | return "base/xfontSize"; 65 | } 66 | 67 | -------------------------------------------------------------------------------- /source/configdialog.h: -------------------------------------------------------------------------------- 1 | /* This file is part of "TcpView For Linux" - network connections viewer for Linux 2 | * Copyright (C) 2021 chipmunk-sm 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include "connectionstatehelper.h" 19 | 20 | #include 21 | #include 22 | 23 | #ifndef CONFIGDIALOG_H 24 | #define CONFIGDIALOG_H 25 | 26 | class QLabel; 27 | class QGridLayout; 28 | class QGestureEvent; 29 | class QScrollArea; 30 | class QPinchGesture; 31 | 32 | class ConfigDialog : public QDialog 33 | { 34 | Q_OBJECT 35 | public: 36 | explicit ConfigDialog(const std::function &callbackUpdate, const std::function &callbackClose, QWidget *parent = nullptr); 37 | ~ConfigDialog() override; 38 | 39 | void setLabelColor(const QColor &frg, const QColor &bkg, QLabel *pLabel); 40 | 41 | public slots: 42 | void onClick(); 43 | void onReset(); 44 | void onBwColor(); 45 | void onWbColor(); 46 | void onBackgroundColor(); 47 | void onDefaultBackgroundColor(); 48 | 49 | protected: 50 | virtual void wheelEvent(QWheelEvent *event) override; 51 | virtual void closeEvent(QCloseEvent *event) override; 52 | virtual bool event(QEvent *event) override; 53 | virtual void keyPressEvent(QKeyEvent *event) override; 54 | virtual void keyReleaseEvent(QKeyEvent *event) override; 55 | 56 | private: 57 | QGridLayout *m_layout_color; 58 | QScrollArea *m_scrollArea_color; 59 | 60 | std::function m_callbackUpdate; 61 | std::function m_callbackClose; 62 | ConnectionStateHelper m_ConnectionStateHelper; 63 | 64 | void tooltipText(const QString &text); 65 | void reloadColor(); 66 | void readGeometry(); 67 | bool gestureEventPinch(QPinchGesture *gesture); 68 | }; 69 | 70 | #endif // CONFIGDIALOG_H 71 | -------------------------------------------------------------------------------- /source/buffer.cpp: -------------------------------------------------------------------------------- 1 | /* This file is part of "TcpView For Linux" - network connections viewer for Linux 2 | * Copyright (C) 2021 chipmunk-sm 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include "buffer.h" 23 | 24 | CBuffer::CBuffer() 25 | : m_pBuffer(nullptr) 26 | , m_bufferSize(0) 27 | { 28 | } 29 | 30 | CBuffer::~CBuffer() 31 | { 32 | Clear(); 33 | } 34 | 35 | void CBuffer::Clear() 36 | { 37 | try 38 | { 39 | 40 | if(m_pBuffer != nullptr) 41 | free(m_pBuffer); 42 | 43 | m_pBuffer = nullptr; 44 | 45 | m_bufferSize = 0; 46 | 47 | } 48 | catch(...) 49 | { 50 | m_error = "Failed free a block allocated by malloc!"; 51 | } 52 | } 53 | 54 | uint8_t *CBuffer::GetBufferPtr(size_t lBufferSize) 55 | { 56 | 57 | if(m_bufferSize >= lBufferSize) 58 | return m_pBuffer; 59 | 60 | ldiv_t roundVal = ldiv(lBufferSize, CSTREAMBUFFER_MIN_INC_SIZE_BYTES); 61 | if(roundVal.rem > 0) 62 | { 63 | lBufferSize = ++roundVal.quot * CSTREAMBUFFER_MIN_INC_SIZE_BYTES; 64 | } 65 | 66 | if(CSTREAMBUFFER_MAX < lBufferSize) 67 | { 68 | m_error = "Maximum buffer size exceeded!"; 69 | return nullptr; 70 | } 71 | 72 | try 73 | { 74 | 75 | auto pNew = reinterpret_cast(malloc(lBufferSize)); 76 | if(pNew == nullptr) 77 | { 78 | m_error = "malloc failed"; 79 | return nullptr; 80 | } 81 | 82 | if(m_bufferSize > 0) 83 | memcpy(pNew, m_pBuffer, m_bufferSize); 84 | 85 | auto lRem = lBufferSize - m_bufferSize; 86 | if(lRem > 0) 87 | memset(pNew + m_bufferSize, 0, lRem); 88 | 89 | Clear(); 90 | 91 | m_pBuffer = pNew; 92 | m_bufferSize = lBufferSize; 93 | 94 | return m_pBuffer; 95 | } 96 | catch(...) 97 | { 98 | m_error = "Unexpected error!"; 99 | return nullptr; 100 | } 101 | } 102 | 103 | size_t CBuffer::GetBufferSize() 104 | { 105 | return m_bufferSize; 106 | } 107 | -------------------------------------------------------------------------------- /source/rootmodule.h: -------------------------------------------------------------------------------- 1 | /* This file is part of "TcpView For Linux" - network connections viewer for Linux 2 | * Copyright (C) 2021 chipmunk-sm 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef CROOTMODULE_H 19 | #define CROOTMODULE_H 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | #include 39 | 40 | #define DEF_STARTCODE 0x010101010 41 | #define TIMEOUT_SERVER_START 1000 42 | 43 | class CRootModule 44 | { 45 | public: 46 | CRootModule(__pid_t processId, std::string fifoName); 47 | ~CRootModule(); 48 | 49 | private: 50 | typedef enum{ 51 | ItemType_ERROR = 0x02, 52 | ItemType_none, 53 | ItemType_inode, 54 | ItemType_cmd, 55 | ItemType_end 56 | }ItemType; 57 | 58 | typedef struct{ 59 | unsigned int startcode1; 60 | unsigned int startcode2; 61 | ItemType command; 62 | unsigned int procId; 63 | unsigned int dataCount; 64 | }ItemInfo; 65 | 66 | public: 67 | void RunServer(); 68 | void RunClient(std::map *pProcInodeList, 69 | std::map *procCommand); 70 | 71 | bool isAbort() const; 72 | void setAbort(); 73 | 74 | private: 75 | unsigned int m_syncCounter; 76 | __pid_t m_processId; 77 | std::string m_fifoNameSrv; 78 | std::string m_fifoNameSrvRun; 79 | int m_fifoSrv; 80 | std::vector m_buffer; 81 | bool m_abort; 82 | 83 | bool LoadProcessInodeList(unsigned int pid, int fifoSrv); 84 | unsigned int GetSocketFromNameTypeA(const char *buf, size_t strLen); 85 | unsigned int GetSocketFromNameTypeB(const char *buf, size_t strLen); 86 | 87 | void GetCommandString(unsigned int pid, int fifoSrv); 88 | 89 | bool WriteFifo(int fifo, const char *pBuffer, size_t size); 90 | int ReadFifo(int fifo, std::vector *pBuffer); 91 | 92 | }; 93 | 94 | #endif // CROOTMODULE_H 95 | -------------------------------------------------------------------------------- /source/ccustomproxymodel.cpp: -------------------------------------------------------------------------------- 1 | /* This file is part of "TcpView For Linux" - network connections viewer for Linux 2 | * Copyright (C) 2021 chipmunk-sm 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include "ccustomproxymodel.h" 19 | 20 | #include 21 | #include 22 | #include "datasource.h" 23 | 24 | CCustomProxyModel::CCustomProxyModel(QObject *parent) 25 | : QSortFilterProxyModel(parent) 26 | { 27 | updateColorMap(); 28 | m_QRegExp.setCaseSensitivity(Qt::CaseInsensitive); 29 | m_QRegExp.setPatternSyntax(QRegExp::RegExp); 30 | } 31 | 32 | void CCustomProxyModel::updateColorMap() 33 | { 34 | m_updateColor = true; 35 | ConnectionStateHelper m_ConnectionStateHelper; 36 | for(auto & item : m_ConnectionStateHelper.getArray()) 37 | { 38 | m_color[item.first].Foreground = item.second.foreground; 39 | m_color[item.first].Background = item.second.background; 40 | } 41 | m_updateColor = false; 42 | } 43 | 44 | void CCustomProxyModel::setFilterRegExpEx(const QString &val) 45 | { 46 | m_QRegExp.setPattern(val); 47 | setFilterRegExp(m_QRegExp); 48 | } 49 | 50 | bool CCustomProxyModel::filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const 51 | { 52 | 53 | if (filterRegExp().isEmpty()) 54 | return true; 55 | 56 | for (int ind = 0; ind < sourceModel()->columnCount(); ind++) 57 | { 58 | QModelIndex index = sourceModel()->index(sourceRow, ind, sourceParent); 59 | if(sourceModel()->data(index).toString().contains(filterRegExp())) 60 | return true; 61 | } 62 | 63 | return false; 64 | } 65 | 66 | QVariant CCustomProxyModel::data(const QModelIndex &index, int role) const 67 | { 68 | if (!index.isValid()) 69 | return QVariant(); 70 | 71 | if (role == Qt::ForegroundRole) 72 | { 73 | auto connectionStateIndex = index.model()->index(index.row(), COLUMN_DATA_STATE, index.parent()); 74 | auto connectionState = static_cast(connectionStateIndex.data(DataTyp::DataTyp_TypState).toInt()); 75 | if (!m_updateColor) 76 | return m_color[connectionState].Foreground; 77 | } 78 | else if (role == Qt::BackgroundRole) 79 | { 80 | auto connectionStateIndex = index.model()->index(index.row(), COLUMN_DATA_STATE, index.parent()); 81 | auto connectionState = static_cast(connectionStateIndex.data(DataTyp::DataTyp_TypState).toInt()); 82 | if (!m_updateColor) 83 | return m_color[connectionState].Background; 84 | } 85 | 86 | return QSortFilterProxyModel::data(index, role); 87 | } 88 | -------------------------------------------------------------------------------- /mainwindow.h: -------------------------------------------------------------------------------- 1 | /* This file is part of "TcpView For Linux" - network connections viewer for Linux 2 | * Copyright (C) 2021 chipmunk-sm 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef MAINWINDOW_H 19 | #define MAINWINDOW_H 20 | 21 | #include 22 | #include 23 | #include 24 | 25 | #include 26 | #include 27 | #include 28 | 29 | #include "source/cconnectionstree.h" 30 | #include "source/ccfontsize.h" 31 | #include "source/clanguage.h" 32 | 33 | #define MAIN_WINDOW_LAYOUT "base/MAIN_WINDOW_LAYOUT" 34 | #define DEFCFG_CONNECTIONTABLE "base/TableHeaderState" 35 | 36 | namespace Ui { 37 | class MainWindow; 38 | } 39 | 40 | class QGestureEvent; 41 | class QPinchGesture; 42 | 43 | class MainWindow : public QMainWindow 44 | { 45 | Q_OBJECT 46 | 47 | public: 48 | explicit MainWindow(QWidget *parent = nullptr); 49 | ~MainWindow() override; 50 | 51 | protected: 52 | virtual void wheelEvent(QWheelEvent *e) override; 53 | virtual bool event(QEvent *event) override; 54 | virtual void keyPressEvent(QKeyEvent *event) override; 55 | virtual void keyReleaseEvent(QKeyEvent *event) override; 56 | virtual void closeEvent(QCloseEvent *) override; 57 | 58 | private slots: 59 | void on_pushButton_displayNames_clicked(); 60 | void on_pushButton_Pause_toggled(bool checked); 61 | void on_pushButton_Record_toggled(bool checked); 62 | void on_pushButton_copyToClipboard_clicked(); 63 | void on_pushButton_SaveToFile_clicked(); 64 | void on_pushButton_whois_clicked(); 65 | void on_pushButton_Settings_clicked(); 66 | void on_lineEdit_include_textChanged(const QString &arg1); 67 | void on_treeView_connection_customContextMenuRequested(const QPoint &pos); 68 | void updateGui(); 69 | void onCurrentSelectionChanged(const QModelIndex current, const QModelIndex previous); 70 | void on_pushButton_resize_clicked(); 71 | 72 | signals: 73 | void callUpdateGui(); 74 | 75 | private: 76 | Ui::MainWindow *ui; 77 | CConnectionsTree m_cconnectionstree; 78 | CCFontSize m_ccfontsize; 79 | bool m_captureEnable; 80 | QString m_whoisText; 81 | QString m_RowText; 82 | QString m_ClipBoardString; 83 | int m_visibleItems; 84 | int m_totalItems; 85 | QFont m_deffont = QApplication::font(); 86 | 87 | void ShowInfoDialog(QString title, QString dialogText, bool readonly); 88 | bool GetAuthGuiName(QString &command, QStringList &cmdArgs); 89 | QString CutLongText(const QString &sourceText, int maxLength); 90 | void UpdateStatusText(); 91 | 92 | void tooltipText(const QString & text); 93 | 94 | void UpdateConfig(); 95 | void CloseConfig(); 96 | 97 | bool gestureEventPinch(QPinchGesture *gesture); 98 | void readGeometry(); 99 | }; 100 | 101 | #endif // MAINWINDOW_H 102 | -------------------------------------------------------------------------------- /source/clanguage.cpp: -------------------------------------------------------------------------------- 1 | /* This file is part of "TcpView For Linux" - network connections viewer for Linux 2 | * Copyright (C) 2021 chipmunk-sm 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include "clanguage.h" 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | 27 | CLanguage::CLanguage() 28 | { 29 | LoadTranslations(QDir(":/translations")); 30 | } 31 | 32 | void CLanguage::LoadTranslations(const QDir &dir) 33 | { 34 | auto fileNames = dir.entryList(QStringList("*.qm"), QDir::Files, QDir::Name); 35 | foreach (const QString &str, fileNames) 36 | { 37 | auto path = dir.filePath(str); 38 | auto langName = ExtractLanguageName(path); 39 | 40 | //qInfo("Translation [%s]\t[%s]\t[%s]", langName.toStdString().c_str() , str.toStdString().c_str(), path.toStdString().c_str()); 41 | 42 | if(langName.length() < 1) 43 | continue; 44 | 45 | if(m_langList.find(langName) != m_langList.end()) 46 | continue; 47 | 48 | m_langList.insert(langName, path); 49 | m_langNames.append(langName); 50 | } 51 | } 52 | 53 | void CLanguage::SetLang(const QString &langName) 54 | { 55 | auto it= m_langList.find(langName); 56 | if(it == m_langList.end()) 57 | return; 58 | if (!m_translator.load(it.value())) 59 | return; 60 | QCoreApplication::instance()->installTranslator(&m_translator); 61 | } 62 | 63 | void CLanguage::SetLangByLocale() 64 | { 65 | //xx_XX 66 | auto localeName = QLocale::system().name(); 67 | if(SetLangByLocale(localeName)) 68 | return; 69 | //xx 70 | #if (QT_VERSION_MAJOR >= 5 && QT_VERSION_MINOR >= 15) || QT_VERSION_MAJOR >= 6 71 | auto list = localeName.split(QRegExp("(_|-)"), Qt::SkipEmptyParts); 72 | #else 73 | auto list = localeName.split(QRegExp("(_|-)"), QString::SkipEmptyParts); 74 | #endif 75 | foreach (auto tmp, list) 76 | { 77 | if(SetLangByLocale(tmp)) 78 | return; 79 | break; 80 | } 81 | } 82 | 83 | bool CLanguage::SetLangByLocale(QString localeName) 84 | { 85 | localeName = QString("language_%1.qm").arg(localeName); 86 | 87 | foreach (auto value, m_langList) 88 | { 89 | if(value.contains(localeName, Qt::CaseInsensitive)) 90 | { 91 | if (!m_translator.load(value)) 92 | return false; 93 | 94 | QCoreApplication::instance()->installTranslator(&m_translator); 95 | return true; 96 | } 97 | } 98 | return false; 99 | } 100 | 101 | const QStringList CLanguage::GetListLangNames() 102 | { 103 | return m_langNames; 104 | } 105 | 106 | QString CLanguage::ExtractLanguageName(const QString &fileName) 107 | { 108 | auto writeLanguageName = QObject::tr("English"); 109 | Q_UNUSED(writeLanguageName) 110 | 111 | QTranslator translator; 112 | translator.load(fileName); 113 | return translator.translate("QObject", "English"); 114 | } 115 | -------------------------------------------------------------------------------- /source/cfilesavewrapper.cpp: -------------------------------------------------------------------------------- 1 | /* This file is part of "TcpView For Linux" - network connections viewer for Linux 2 | * Copyright (C) 2021 chipmunk-sm 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include "cfilesavewrapper.h" 19 | 20 | #include 21 | 22 | CFileSaveWrapper::CFileSaveWrapper() 23 | : m_parent(nullptr) 24 | , m_pQFile(nullptr) 25 | , m_pQXmlStreamWriter(nullptr) 26 | , m_pQTextStream(nullptr) 27 | { 28 | } 29 | 30 | CFileSaveWrapper::~CFileSaveWrapper() 31 | { 32 | Close(); 33 | } 34 | 35 | void CFileSaveWrapper::Open(const QString fileName, const QString fileType, QWidget *parent) 36 | { 37 | 38 | m_parent = parent; 39 | 40 | m_pQFile = new QFile(fileName); 41 | if (!m_pQFile->open(QFile::WriteOnly | QFile::Text)) 42 | { 43 | QString mess(QObject::tr("Error: Cannot write file\n") + fileName + "\n" + m_pQFile->errorString()); 44 | QMessageBox::critical(m_parent, QObject::tr("Save"), mess, QMessageBox::Ok); 45 | return; 46 | } 47 | 48 | if(fileType.startsWith("xml", Qt::CaseInsensitive)) 49 | { 50 | m_pQXmlStreamWriter = new QXmlStreamWriter(m_pQFile); 51 | m_pQXmlStreamWriter->setAutoFormatting(true); 52 | m_pQXmlStreamWriter->writeStartDocument(); 53 | m_pQXmlStreamWriter->writeStartElement("root"); 54 | } 55 | else if(fileType.startsWith("csv", Qt::CaseInsensitive)) 56 | { 57 | m_pQTextStream = new QTextStream(m_pQFile); 58 | } 59 | } 60 | 61 | void CFileSaveWrapper::Close() 62 | { 63 | 64 | if(m_pQXmlStreamWriter != nullptr) 65 | { 66 | m_pQXmlStreamWriter->writeEndDocument(); 67 | delete m_pQXmlStreamWriter; 68 | m_pQXmlStreamWriter = nullptr; 69 | } 70 | 71 | if(m_pQTextStream != nullptr) 72 | { 73 | m_pQTextStream->flush(); 74 | delete m_pQTextStream; 75 | m_pQTextStream = nullptr; 76 | } 77 | 78 | if (m_pQFile != nullptr) 79 | { 80 | m_pQFile->close(); 81 | if (m_pQFile->error()) 82 | { 83 | QString mess(QObject::tr("Error: Cannot write file\n") + m_pQFile->errorString()); 84 | QMessageBox::critical(m_parent, QObject::tr("Save"), mess, QMessageBox::Ok); 85 | } 86 | delete m_pQFile; 87 | m_pQFile = nullptr; 88 | } 89 | m_tag.clear(); 90 | } 91 | 92 | void CFileSaveWrapper::ElemStart(const QString Val) 93 | { 94 | if( m_pQXmlStreamWriter) 95 | m_pQXmlStreamWriter->writeStartElement(Val); 96 | 97 | m_tag.push_back(Val); 98 | } 99 | 100 | void CFileSaveWrapper::ElemVal(const QString Val) 101 | { 102 | if( m_pQXmlStreamWriter) 103 | m_pQXmlStreamWriter->writeCharacters(Val); 104 | else if(m_pQTextStream) 105 | *m_pQTextStream << Val; 106 | } 107 | 108 | void CFileSaveWrapper::ElemEnd(const QString Val) 109 | { 110 | if( m_pQXmlStreamWriter) 111 | m_pQXmlStreamWriter->writeEndElement(/*Val*/); 112 | else if(m_pQTextStream) 113 | *m_pQTextStream << ((Val.compare("c") == 0) ? "\t" : "\n"); 114 | 115 | if(m_tag.isEmpty() || m_tag.last().compare(Val) != 0) 116 | throw std::runtime_error("Error writeEndElement."); 117 | 118 | m_tag.pop_back(); 119 | } 120 | 121 | 122 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TcpView For Linux 2 | 3 | ## Graphical network connections viewer for Linux 4 | 5 | Buy Me A Coffee 6 | 7 | **Project status (appveyor)** 8 | [![Build status](https://ci.appveyor.com/api/projects/status/manttq3gao1gqysr?svg=true)](https://ci.appveyor.com/project/chipmunk-sm/tcpview) 9 | 10 | **Master branch status (appveyor)** 11 | [![Build status](https://ci.appveyor.com/api/projects/status/manttq3gao1gqysr/branch/master?svg=true)](https://ci.appveyor.com/project/chipmunk-sm/tcpview/branch/master) 12 | 13 | ### To get the last release version, please use the PPA: 14 | https://launchpad.net/~chipmunk.sm/+archive/ubuntu/ppa 15 | 16 | ```bash 17 | $ sudo add-apt-repository ppa:chipmunk.sm/ppa 18 | $ sudo apt-get update 19 | $ sudo apt-get install tcpview 20 | ``` 21 | 22 | ## Debian packages (.deb) 23 | https://launchpad.net/~chipmunk.sm/+archive/ubuntu/ppa/+packages 24 | 25 | Home page: 26 | 27 | https://github.com/chipmunk-sm/tcpview 28 | 29 | 30 | ![screen](https://user-images.githubusercontent.com/29524958/118386224-7e994e00-b605-11eb-8a24-2feef8a62815.png) 31 | 32 | ![screenshot_201708111](https://user-images.githubusercontent.com/29524958/29194415-231f2b9e-7e32-11e7-8c94-8eac6ea0bf98.png) 33 | 34 | 35 | ## Description 36 | TcpView For Linux. Graphical network connections viewer for Linux. 37 | ``` 38 | Show processes – Display the path of the executable process. (Password required) 39 | Pause - Stop loading new records 40 | Record - Stop delete old records. 41 | Copy - Copy the data of a row to the clipboard 42 | Save – Export data to a CSV or XML file 43 | Whois - Service gives you the ability to find out the registered domain holder. 44 | *Zoom - ctrl + mouse wheel 45 | ``` 46 | ## How does it work? 47 | ### "Base module" 48 | Read and parse the information available from 49 | ``` 50 | /proc/net/tcp 51 | /proc/net/udp 52 | /proc/net/tcp6 53 | /proc/net/udp6 54 | /proc/net/raw 55 | /proc/net/raw6 56 | ``` 57 | The data used from output is: 58 | ``` 59 | sl - The number of the line in the output listing. 60 | local_address 61 | rem_address 62 | st - The socket status. 63 | Uid - The ID of the user that owns the socket. 64 | Inode - A cryptic-looking number that identifies the socket to the Linux virtual filesystem. 65 | ``` 66 | 67 | ### "Root module" 68 | Loop through /proc/pid/fd/ for collect "inode list" and associated "command line" data 69 | 70 | # How to build 71 | 72 | ## Install the build-dependencies on the host system 73 | 74 | ```bash 75 | $ sudo apt-get install build-essential 76 | $ sudo apt-get install qtcreator 77 | $ sudo apt-get install qt5-default 78 | $ sudo apt-get install uuid-dev 79 | ``` 80 | 81 | ## Clone 82 | Open terminal in your preferred folder: 83 | 84 | ```bash 85 | $ git clone https://github.com/chipmunk-sm/tcpview.git 86 | ``` 87 | 88 | ## Build 89 | 90 | Either open `tcpview.pro` with Qt Creator for editing and building, or from the terminal: 91 | 92 | ```bash 93 | $ cd tcpview 94 | $ qmake 95 | $ make 96 | ``` 97 | 98 | ## Run tcpview 99 | 100 | ```bash 101 | $ ./tcpview 102 | ``` 103 | 104 | # Translation 105 | 106 | Use the Qt Linguist tool to translate text 107 | 108 | ```bash 109 | $ sudo apt-get install qttools5-dev-tools 110 | ``` 111 | 112 | Open tcpview folder with terminal and update translations: 113 | 114 | ```bash 115 | $ lupdate -no-obsolete -verbose -pro tcpview.pro 116 | ``` 117 | 118 | Open all editable translations: 119 | 120 | ```bash 121 | $ cd translations 122 | $ linguist language_cs.ts language_de.ts language_es.ts language_fr.ts language_ja.ts language_pl.ts language_ru.ts language_sl.ts language_zh_CN.ts language_zh_TW.ts 123 | $ cd .. 124 | ``` 125 | 126 | And update `.qm` files: 127 | 128 | ```bash 129 | $ lrelease -removeidentical -compress tcpview.pro 130 | ``` 131 | 132 | Finally, [rebuild tcpview](#how-to-build). 133 | 134 | ## Adding new translations 135 | 136 | Add a new translations `xx.ts` file to tcpview.pro, rebuild tcpview and add your new `xx.qm` to `tcpview.qrc`. Finally [rebuild tcpview](#how-to-build). 137 | -------------------------------------------------------------------------------- /tcpview.pro: -------------------------------------------------------------------------------- 1 | #/* This file is part of "TcpView For Linux" - network connections viewer for Linux 2 | # * Copyright (C) 2021 chipmunk-sm 3 | # * 4 | # * This program is free software: you can redistribute it and/or modify 5 | # * it under the terms of the GNU General Public License as published by 6 | # * the Free Software Foundation, either version 3 of the License, or 7 | # * (at your option) any later version. 8 | # * 9 | # * This program is distributed in the hope that it will be useful, 10 | # * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | # * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | # * GNU General Public License for more details. 13 | # * 14 | # * You should have received a copy of the GNU General Public License 15 | # * along with this program. If not, see . 16 | # */ 17 | 18 | QT += core gui 19 | 20 | CONFIG += c++11 21 | 22 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 23 | 24 | LIBS += -luuid 25 | 26 | TARGET = tcpview 27 | TEMPLATE = app 28 | 29 | 30 | SOURCES += main.cpp\ 31 | mainwindow.cpp \ 32 | source/buffer.cpp \ 33 | source/configdialog.cpp \ 34 | source/connectionstatehelper.cpp \ 35 | source/cstylehelperex.cpp \ 36 | source/datasource.cpp \ 37 | source/rootmodule.cpp \ 38 | source/cconnectionstree.cpp \ 39 | source/ccustomproxymodel.cpp \ 40 | source/ccfontsize.cpp \ 41 | source/cfilesavewrapper.cpp \ 42 | source/cportservicenames.cpp \ 43 | source/cusername.cpp \ 44 | source/clanguage.cpp 45 | 46 | HEADERS += mainwindow.h \ 47 | source/buffer.h \ 48 | source/configdialog.h \ 49 | source/connectionstatehelper.h \ 50 | source/cstylehelperex.h \ 51 | source/datasource.h \ 52 | source/rootmodule.h \ 53 | source/cconnectionstree.h \ 54 | source/tableheadercaption.h \ 55 | source/ccustomproxymodel.h \ 56 | source/ccfontsize.h \ 57 | source/cfilesavewrapper.h \ 58 | source/cportservicenames.h \ 59 | source/cusername.h \ 60 | source/clanguage.h \ 61 | source/defined.h 62 | 63 | FORMS += mainwindow.ui 64 | 65 | DISTFILES += \ 66 | data/tcpview.svg \ 67 | data/tcpviewU.svg \ 68 | data/tcpview.desktop \ 69 | debian/compat \ 70 | debian/control \ 71 | debian/copyright \ 72 | debian/tcpview.install \ 73 | debian/rules \ 74 | debian/source/format \ 75 | README.md \ 76 | LICENSE \ 77 | debian/changelog 78 | 79 | RESOURCES += \ 80 | tcpview.qrc 81 | 82 | # $HOME/Qt/5.15.2/gcc_64/bin/lupdate -no-obsolete -verbose -pro tcpview.pro 83 | # lupdate -no-obsolete -verbose -pro tcpview.pro 84 | 85 | # cd translations 86 | 87 | # $HOME/Qt/5.15.2/gcc_64/bin/linguist language_en.ts language_cs.ts language_de.ts language_es.ts language_fr.ts language_ja.ts language_pl.ts language_ru.ts language_sl.ts language_zh_CN.ts language_zh_TW.ts 88 | # language_en.ts language_cs.ts language_de.ts language_es.ts language_fr.ts language_ja.ts language_pl.ts language_ru.ts language_sl.ts language_zh_CN.ts language_zh_TW.ts 89 | 90 | # cd .. 91 | 92 | # $HOME/Qt/5.15.2/gcc_64/bin/lrelease -removeidentical -compress tcpview.pro 93 | # lrelease -removeidentical -compress tcpview.pro 94 | 95 | TRANSLATIONS += \ 96 | translations/language_en.ts \ 97 | translations/language_cs.ts \ 98 | translations/language_de.ts \ 99 | translations/language_es.ts \ 100 | translations/language_fr.ts \ 101 | translations/language_ja.ts \ 102 | translations/language_pl.ts \ 103 | translations/language_ru.ts \ 104 | translations/language_sl.ts \ 105 | translations/language_zh_CN.ts \ 106 | translations/language_zh_TW.ts 107 | 108 | #af Afrikaans 109 | #sq Albanian 110 | #ar Arabic 111 | #eu Basque 112 | #be Belarusian 113 | #bs Bosnian 114 | #bg Bulgarian 115 | #ca Catalan 116 | #hr Croatian 117 | #zh_cn Chinese (Simplified) 118 | #zh_tw Chinese (Traditional) 119 | #cs Czech 120 | #da Danish 121 | #nl Dutch 122 | #en English 123 | #en_us English (US) 124 | #et Estonian 125 | #fa Farsi 126 | #fil Filipino 127 | #fi Finnish 128 | #fr French 129 | #fr_ca French (Canada) 130 | #ga Gaelic 131 | #gl Gallego 132 | #ka Georgian 133 | #de German 134 | #de_du German (Personal) 135 | #el Greek 136 | #gu Gujarati 137 | #he Hebrew 138 | #hi Hindi 139 | #hu Hungarian 140 | #is Icelandic 141 | #id Indonesian 142 | #it Italian 143 | #ja Japanese 144 | #kn Kannada 145 | #km Khmer 146 | #ko Korean 147 | #lo Lao 148 | #lt Lithuanian 149 | #lv Latvian 150 | #ml Malayalam 151 | #ms Malaysian 152 | #mi_tn Maori (Ngai Tahu) 153 | #mi_wwow Maori (Waikoto Uni) 154 | #mn Mongolian 155 | #no Norwegian 156 | #no_gr Norwegian (Primary) 157 | #nn Nynorsk 158 | #pl Polish 159 | #pt Portuguese 160 | #pt_br Portuguese (Brazil) 161 | #ro Romanian 162 | #ru Russian 163 | #sm Samoan 164 | #sr Serbian 165 | #sk Slovak 166 | #sl Slovenian 167 | #so Somali 168 | #es Spanish (International) 169 | #sv Swedish 170 | #tl Tagalog 171 | #ta Tamil 172 | #th Thai 173 | #to Tongan 174 | #tr Turkish 175 | #uk Ukrainian 176 | #vi Vietnamese 177 | -------------------------------------------------------------------------------- /source/connectionstatehelper.cpp: -------------------------------------------------------------------------------- 1 | /* This file is part of "TcpView For Linux" - network connections viewer for Linux 2 | * Copyright (C) 2021 chipmunk-sm 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include "connectionstatehelper.h" 19 | #include 20 | #include 21 | #include 22 | #include 23 | 24 | ConnectionStateHelper::ConnectionStateHelper() 25 | { 26 | updatetColor(false); 27 | } 28 | 29 | QString ConnectionStateHelper::getStateName(eConnectionTcpState id) 30 | { 31 | auto ptr = m_state.find(id); 32 | if (ptr != m_state.end()) 33 | return ptr->second.name; 34 | return QString::number(id); 35 | } 36 | 37 | QColor ConnectionStateHelper::getStateColor(eConnectionTcpState id, bool foreground) 38 | { 39 | auto ptr = m_state.find(id); 40 | if (ptr != m_state.end()) 41 | return foreground ? ptr->second.foreground : ptr->second.background; 42 | return foreground ? QColor(0x00, 0x00, 0x00) : QColor(0xFF,0xFF,0xFF); 43 | } 44 | 45 | void ConnectionStateHelper::saveColor(eConnectionTcpState id, const QColor &color, bool foreground) 46 | { 47 | QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName()); 48 | settings.setValue(getKeyName(id, foreground), color); 49 | if (foreground) 50 | m_state[id].foreground = color; 51 | else 52 | m_state[id].background = color; 53 | } 54 | 55 | const std::map ConnectionStateHelper::getArray() const 56 | { 57 | return m_state; 58 | } 59 | 60 | QString ConnectionStateHelper::getKeyName(eConnectionTcpState id, bool foreground) 61 | { 62 | return QString("connectionState/colorid_%1_%2").arg(id).arg(foreground ? "F" : "B"); 63 | } 64 | 65 | void ConnectionStateHelper::updatetColor(bool reset) 66 | { 67 | initParameters(CONNECTION_TCP_EMPTY , QColor(0x7F,0x7F,0x7F), QColor(0xFF,0xFF,0xFF), QObject::tr(""), reset); 68 | initParameters(CONNECTION_TCP_ESTABLISHED, QColor(0x00,0x7F,0x00), QColor(0xFF,0xFF,0xFF), QObject::tr("established"), reset); 69 | initParameters(CONNECTION_TCP_SYN_SENT , QColor(0x00,0xb4,0x57), QColor(0xFF,0xFF,0xFF), QObject::tr("syn_sent"), reset); 70 | initParameters(CONNECTION_TCP_SYN_RECV , QColor(0x00,0x00,0x00), QColor(0xFF,0xFF,0xFF), QObject::tr("syn_recv"), reset); 71 | initParameters(CONNECTION_TCP_FIN_WAIT1 , QColor(0x00,0x00,0x00), QColor(0xFF,0xFF,0xFF), QObject::tr("fin_wait1"), reset); 72 | initParameters(CONNECTION_TCP_FIN_WAIT2 , QColor(0x00,0x00,0x00), QColor(0xFF,0xFF,0xFF), QObject::tr("fin_wait2"), reset); 73 | initParameters(CONNECTION_TCP_TIME_WAIT , QColor(0x8b,0x00,0x46), QColor(0xFF,0xFF,0xFF), QObject::tr("time_wait"), reset); 74 | initParameters(CONNECTION_TCP_CLOSE , QColor(0x00,0x00,0xff), QColor(0xFF,0xFF,0xFF), QObject::tr("unconnected"), reset); 75 | initParameters(CONNECTION_TCP_CLOSE_WAIT , QColor(0xb1,0x00,0xb1), QColor(0xFF,0xFF,0xFF), QObject::tr("close_wait"), reset); 76 | initParameters(CONNECTION_TCP_LAST_ACK , QColor(0x7e,0x7e,0x00), QColor(0xFF,0xFF,0xFF), QObject::tr("last_ack"), reset); 77 | initParameters(CONNECTION_TCP_LISTEN , QColor(0x00,0xaa,0x7f), QColor(0xFF,0xFF,0xFF), QObject::tr("listen"), reset); 78 | initParameters(CONNECTION_TCP_CLOSING , QColor(0xaf,0x00,0x58), QColor(0xFF,0xFF,0xFF), QObject::tr("closing"), reset); 79 | initParameters(CONNECTION_TCP_CLOSED , QColor(0xc8,0x00,0x64), QColor(0xFF,0xFF,0xFF), QObject::tr("closed"), reset); 80 | initParameters(CONNECTION_REMOVED , QColor(0xFF,0x00,0x00), QColor(0xFF,0xFF,0xFF), QObject::tr("removed"), reset); 81 | } 82 | 83 | void ConnectionStateHelper::setBwColor() { 84 | QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName()); 85 | for (const auto & item : m_state) { 86 | settings.setValue(getKeyName(item.first, true), QColor(0xFF,0xFF,0xFF)); 87 | settings.setValue(getKeyName(item.first, false), QColor(0x00,0x00,0x00)); 88 | m_state[item.first].foreground = settings.value(getKeyName(item.first, true)).value(); 89 | m_state[item.first].background = settings.value(getKeyName(item.first, false)).value(); 90 | } 91 | } 92 | 93 | void ConnectionStateHelper::setWbColor() 94 | { 95 | QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName()); 96 | for (const auto & item : m_state) { 97 | settings.setValue(getKeyName(item.first, true), QColor(0x00,0x00,0x00)); 98 | settings.setValue(getKeyName(item.first, false), QColor(0xFF,0xFF,0xFF)); 99 | m_state[item.first].foreground = settings.value(getKeyName(item.first, true)).value(); 100 | m_state[item.first].background = settings.value(getKeyName(item.first, false)).value(); 101 | } 102 | } 103 | 104 | void ConnectionStateHelper::initParameters(eConnectionTcpState id, QColor defColorForeground, QColor defColorBackground, const QString & name, bool reset) 105 | { 106 | 107 | QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName()); 108 | 109 | if(reset) 110 | { 111 | settings.setValue(getKeyName(id, true), defColorForeground); 112 | settings.setValue(getKeyName(id, false), defColorBackground); 113 | } 114 | 115 | defColorForeground = settings.value(getKeyName(id, true), defColorForeground).value(); 116 | defColorBackground = settings.value(getKeyName(id, false), defColorBackground).value(); 117 | 118 | m_state[id].name = name; 119 | m_state[id].foreground = defColorForeground; 120 | m_state[id].background = defColorBackground; 121 | 122 | settings.setValue(getKeyName(id, true), defColorForeground); 123 | settings.setValue(getKeyName(id, false), defColorBackground); 124 | 125 | } 126 | -------------------------------------------------------------------------------- /source/datasource.h: -------------------------------------------------------------------------------- 1 | /* This file is part of "TcpView For Linux" - network connections viewer for Linux 2 | * Copyright (C) 2021 chipmunk-sm 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #ifndef PROCESSLOADER_H 19 | #define PROCESSLOADER_H 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #include 39 | #include 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | 48 | #include "cportservicenames.h" 49 | #include "rootmodule.h" 50 | 51 | #define USECONSTFUNCTION 52 | 53 | typedef enum eConnectionTcpState{ 54 | CONNECTION_TCP_EMPTY, 55 | CONNECTION_TCP_ESTABLISHED, 56 | CONNECTION_TCP_SYN_SENT, 57 | CONNECTION_TCP_SYN_RECV, 58 | CONNECTION_TCP_FIN_WAIT1, 59 | CONNECTION_TCP_FIN_WAIT2, 60 | CONNECTION_TCP_TIME_WAIT, 61 | CONNECTION_TCP_CLOSE, 62 | CONNECTION_TCP_CLOSE_WAIT, 63 | CONNECTION_TCP_LAST_ACK, 64 | CONNECTION_TCP_LISTEN, 65 | CONNECTION_TCP_CLOSING, 66 | CONNECTION_TCP_CLOSED, 67 | CONNECTION_REMOVED = 0xfc 68 | }eConnectionTcpState; 69 | 70 | typedef enum eColumnData{ 71 | COLUMN_DATA_PROTOCOL, 72 | COLUMN_DATA_LOCALHOST, 73 | COLUMN_DATA_LOCALADDRESS, 74 | COLUMN_DATA_LOCALPORT, 75 | COLUMN_DATA_STATE, 76 | COLUMN_DATA_REMOTEHOST, 77 | COLUMN_DATA_REMOTEADDRESS, 78 | COLUMN_DATA_REMOTEPORT, 79 | COLUMN_DATA_UID, 80 | COLUMN_DATA_INODE, 81 | COLUMN_DATA_TIME, 82 | COLUMN_DATA_COMMAND, 83 | 84 | COLUMN_DATA_COUNT 85 | }eColumnData; 86 | 87 | typedef enum eNetType{ 88 | conn_tcp, 89 | conn_udp, 90 | conn_tcp6, 91 | conn_udp6, 92 | conn_raw, 93 | conn_raw6 94 | }eNetType; 95 | 96 | typedef enum eProcPath{ 97 | proc_net_tcp = 1, // Contains detailed TCP socket information. 98 | proc_net_tcp6, // 99 | proc_net_udp, // Contains detailed UDP socket information. 100 | proc_net_udp6, // 101 | proc_net_raw, // Lists raw device statistics. 102 | proc_net_raw6, // 103 | }eProcPath; 104 | 105 | typedef struct SocketInfo{ 106 | char localAddr[INET6_ADDRSTRLEN + 1]; 107 | char localHost[NI_MAXHOST + 1]; 108 | char localPort[NI_MAXSERV + 1]; 109 | char remoteAddr[INET6_ADDRSTRLEN + 1]; 110 | char remoteHost[NI_MAXHOST + 1]; 111 | char remotePort[NI_MAXSERV + 1]; 112 | char command[_POSIX_PATH_MAX + 2]; 113 | bool commandUpdate; 114 | bool stateUpdate; 115 | unsigned int uid; // user id 116 | eNetType netType; 117 | unsigned long long inode; // connecton id 118 | uuid_t uuid; // unique ID for item 119 | time_t last_time; 120 | uint state; 121 | unsigned int deleteItem; 122 | struct in6_addr loc6; 123 | struct in6_addr rem6; 124 | struct in_addr loc4; 125 | struct in_addr rem4; 126 | }SocketInfo; 127 | 128 | class CDataSource 129 | { 130 | public: 131 | static CDataSource & Instance() 132 | { 133 | static CDataSource thisInstance; 134 | return thisInstance; 135 | } 136 | CDataSource(const CDataSource &) = delete; 137 | CDataSource(const CDataSource&&) = delete; 138 | CDataSource& operator=(const CDataSource&) = delete; 139 | CDataSource& operator=(const CDataSource&&)= delete; 140 | 141 | private: 142 | explicit CDataSource(); 143 | ~CDataSource(); 144 | 145 | public: 146 | 147 | void Init(const std::function &callbackUpdate); 148 | 149 | void setAbort(); 150 | 151 | std::unordered_map *GetConnectionsList(); 152 | void FreeConnectionsList(); 153 | 154 | bool InitRootLoader(std::string name); 155 | bool rootLoaderActive(); 156 | void shutdownRootModule(); 157 | 158 | int timeoutSec() const; 159 | void setTimeoutSec(int timeoutSec); 160 | 161 | #ifdef USECONSTFUNCTION 162 | bool pauseUpdate() const; 163 | #else 164 | bool pauseUpdate(); 165 | #endif 166 | void setPauseUpdate(bool pauseUpdate); 167 | 168 | private: 169 | void ThreadMain(); 170 | void UpdateTable(); 171 | 172 | static void LoadConnections(eNetType netType, 173 | const char *commandLine, 174 | std::unordered_map *pSocketList, 175 | CPortServiceNames *pCPortServiceNames, 176 | const time_t nowtime); 177 | 178 | static bool LoadCmd(unsigned long long inode, 179 | std::map *procCommand, 180 | std::map *procInodeList, 181 | char *pBuff, 182 | size_t bufferLen); 183 | 184 | void DomainNamesResolver(SocketInfo &socket_info); 185 | 186 | std::map m_eNetTypeList; 187 | std::unordered_map m_socketList; 188 | std::shared_ptr m_rootModule; 189 | CPortServiceNames m_portServiceNames; 190 | std::function m_callbackUpdate; 191 | bool m_threadExit = true; 192 | bool m_threadStop = true; 193 | bool m_pauseUpdate = true; 194 | std::atomic_bool m_updateInProgress = ATOMIC_FLAG_INIT; 195 | bool m_connectionsListInUse = false; 196 | int m_removeRecordTimeoutSec = 10; 197 | 198 | #ifdef USECONSTFUNCTION 199 | 200 | #else 201 | /*mutable*/ std::mutex m_run_update; 202 | #endif 203 | }; 204 | 205 | #endif // PROCESSLOADER_H 206 | -------------------------------------------------------------------------------- /mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 1006 10 | 360 11 | 12 | 13 | 14 | TcpView For Linux 15 | 16 | 17 | 18 | 19 | 0 20 | 21 | 22 | 0 23 | 24 | 25 | 0 26 | 27 | 28 | 0 29 | 30 | 31 | 0 32 | 33 | 34 | 35 | 36 | Filter 37 | 38 | 39 | Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter 40 | 41 | 42 | 9 43 | 44 | 45 | 46 | 47 | 48 | 49 | Include word - | 50 | word1|word2|word3 51 | 52 | Word Boundaries - \b 53 | \bWord - start with Word 54 | Word\b - end with Word 55 | \bWord\b - whole words only 56 | 57 | Example. Only UDP and TCP (not TCP6 ot UDP6) 58 | tcp\b|udp\b 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | QLayout::SetMinimumSize 67 | 68 | 69 | 5 70 | 71 | 72 | 5 73 | 74 | 75 | 5 76 | 77 | 78 | 5 79 | 80 | 81 | 5 82 | 83 | 84 | 85 | 86 | 87 | 0 88 | 0 89 | 90 | 91 | 92 | true 93 | 94 | 95 | WHOIS - Lookup service to search for the domain name registration information 96 | 97 | 98 | whois 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 0 107 | 0 108 | 109 | 110 | 111 | true 112 | 113 | 114 | Stop reading new records 115 | 116 | 117 | Pause 118 | 119 | 120 | true 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 0 129 | 0 130 | 131 | 132 | 133 | true 134 | 135 | 136 | Display the path of the executable process. (Password required) 137 | 138 | 139 | Show processes 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 0 148 | 0 149 | 150 | 151 | 152 | true 153 | 154 | 155 | Copy to Clipboard 156 | 157 | 158 | Copy 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 0 167 | 0 168 | 169 | 170 | 171 | true 172 | 173 | 174 | Save to XML or CVS 175 | 176 | 177 | Save 178 | 179 | 180 | 181 | 182 | 183 | 184 | <a href="https://github.com/chipmunk-sm/tcpview">https://github.com/chipmunk-sm/tcpview</a> 185 | 186 | 187 | Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter 188 | 189 | 190 | true 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 0 199 | 0 200 | 201 | 202 | 203 | true 204 | 205 | 206 | Do not cleanup deleted records 207 | 208 | 209 | Record 210 | 211 | 212 | true 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 0 221 | 0 222 | 223 | 224 | 225 | true 226 | 227 | 228 | Settings 229 | 230 | 231 | Settings 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 0 240 | 0 241 | 242 | 243 | 244 | true 245 | 246 | 247 | Adjust columns to match text size 248 | 249 | 250 | Auto Fit 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | Qt::CustomContextMenu 261 | 262 | 263 | QAbstractItemView::NoEditTriggers 264 | 265 | 266 | true 267 | 268 | 269 | false 270 | 271 | 272 | false 273 | 274 | 275 | true 276 | 277 | 278 | true 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | -------------------------------------------------------------------------------- /source/cconnectionstree.cpp: -------------------------------------------------------------------------------- 1 | /* This file is part of "TcpView For Linux" - network connections viewer for Linux 2 | * Copyright (C) 2021 chipmunk-sm 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include "cconnectionstree.h" 19 | 20 | #include 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | 29 | 30 | CConnectionsTree::CConnectionsTree() 31 | : m_pProxyModel(nullptr) 32 | { 33 | PrepareTableCaptionString(); 34 | PrepareTableProtocolString(); 35 | } 36 | 37 | CConnectionsTree::~CConnectionsTree() 38 | { 39 | delete m_pProxyModel; 40 | } 41 | 42 | void CConnectionsTree::PrepareTableCaptionString() 43 | { 44 | // caption captionSample captionToolTip 45 | m_caption.insert(COLUMN_DATA_PROTOCOL, TableHeaderCaption(QObject::tr("Protocol"), QObject::tr("tcp6"), QObject::tr("Protocol"))); 46 | m_caption.insert(COLUMN_DATA_LOCALHOST, TableHeaderCaption(QObject::tr("Local Host"), QObject::tr("Local Host"), QObject::tr("Local Host"))); 47 | m_caption.insert(COLUMN_DATA_LOCALADDRESS, TableHeaderCaption(QObject::tr("Local Address"), QObject::tr("255.255.255.255"), QObject::tr("Local Address"))); 48 | m_caption.insert(COLUMN_DATA_LOCALPORT, TableHeaderCaption(QObject::tr("Local Port"), QObject::tr("65535"), QObject::tr("Local Port"))); 49 | m_caption.insert(COLUMN_DATA_STATE, TableHeaderCaption(QObject::tr("State"), QObject::tr("ESTABLISHED"), QObject::tr("State"))); 50 | m_caption.insert(COLUMN_DATA_REMOTEHOST, TableHeaderCaption(QObject::tr("Remote Host"), QObject::tr("Remote Host"), QObject::tr("Remote Host"))); 51 | m_caption.insert(COLUMN_DATA_REMOTEADDRESS, TableHeaderCaption(QObject::tr("Remote Address"), QObject::tr("255.255.255.255"), QObject::tr("Remote Address"))); 52 | m_caption.insert(COLUMN_DATA_REMOTEPORT, TableHeaderCaption(QObject::tr("Remote Port"), QObject::tr("65535"), QObject::tr("Remote Port"))); 53 | m_caption.insert(COLUMN_DATA_UID, TableHeaderCaption(QObject::tr("User"), QObject::tr("0000000"), QObject::tr("User"))); 54 | m_caption.insert(COLUMN_DATA_INODE, TableHeaderCaption(QObject::tr("Inode"), QObject::tr("0000000"), QObject::tr("Inode"))); 55 | m_caption.insert(COLUMN_DATA_TIME, TableHeaderCaption(QObject::tr("Time"), QObject::tr("2017-01-01 00:00:00"), QObject::tr("Time"))); 56 | m_caption.insert(COLUMN_DATA_COMMAND, TableHeaderCaption(QObject::tr("Process path"), QObject::tr("Process path"), QObject::tr("Process path"))); 57 | } 58 | 59 | void CConnectionsTree::PrepareTableProtocolString() 60 | { 61 | m_protocol.insert(conn_tcp, QObject::tr("tcp")); 62 | m_protocol.insert(conn_udp, QObject::tr("udp")); 63 | m_protocol.insert(conn_tcp6, QObject::tr("tcp6")); 64 | m_protocol.insert(conn_udp6, QObject::tr("udp6")); 65 | m_protocol.insert(conn_raw, QObject::tr("raw")); 66 | m_protocol.insert(conn_raw6, QObject::tr("raw6")); 67 | } 68 | 69 | void CConnectionsTree::UpdateData(SocketInfo * dataSource, bool disableCleanup) 70 | { 71 | 72 | char guid[64]; 73 | uuid_unparse(dataSource->uuid, guid); 74 | QUuid uuid(guid); 75 | 76 | auto src = qobject_cast(m_pProxyModel->sourceModel()); 77 | if(src == nullptr) 78 | throw std::runtime_error("Error Update Proxy Data qobject_cast(m_pProxyModel->sourceModel())"); 79 | 80 | auto start = src->index(0, COLUMN_DATA_STATE); 81 | auto pParent = src->parent(start); 82 | auto totalRow = src->rowCount(pParent); 83 | QModelIndex Item; 84 | for (int rowTmp = 0; rowTmp < totalRow; ++rowTmp) 85 | { 86 | auto idx = src->index(rowTmp, COLUMN_DATA_STATE, pParent); 87 | if (!idx.isValid()) 88 | continue; 89 | auto rowid = src->data(idx, DataTyp::DataTyp_TypId).toUuid(); 90 | if (rowid == uuid) 91 | { 92 | Item = idx; 93 | break; 94 | } 95 | } 96 | 97 | if(!disableCleanup && Item.isValid() && dataSource->deleteItem > 0) 98 | { 99 | src->removeRow(Item.row()); 100 | return; 101 | } 102 | 103 | if(Item.isValid()) 104 | { 105 | auto iRow = Item.row(); 106 | if(dataSource->stateUpdate) 107 | { 108 | dataSource->stateUpdate = false; 109 | src->setData(src->index(iRow, COLUMN_DATA_STATE), m_ConnectionStateHelper.getStateName(static_cast(dataSource->state))); 110 | src->setData(src->index(iRow, COLUMN_DATA_STATE), dataSource->state, DataTyp::DataTyp_TypState); 111 | emit src->dataChanged(src->index(iRow, 0), src->index(iRow, src->columnCount() - 1)); 112 | } 113 | 114 | if(dataSource->commandUpdate) 115 | { 116 | dataSource->commandUpdate = false; 117 | src->setData(src->index(iRow, COLUMN_DATA_COMMAND), dataSource->command); 118 | } 119 | } 120 | else 121 | { 122 | auto iRow = src->rowCount(); 123 | src->insertRows(iRow, 1); 124 | 125 | auto tmpTime = QDateTime::currentDateTime().toString("yy-MM-dd hh:mm:ss.zzz"); 126 | 127 | src->setData(src->index(iRow, COLUMN_DATA_PROTOCOL), m_protocol[dataSource->netType]); 128 | src->setData(src->index(iRow, COLUMN_DATA_LOCALHOST), dataSource->localHost); 129 | src->setData(src->index(iRow, COLUMN_DATA_LOCALADDRESS), dataSource->localAddr); 130 | src->setData(src->index(iRow, COLUMN_DATA_LOCALPORT), dataSource->localPort); 131 | src->setData(src->index(iRow, COLUMN_DATA_STATE), m_ConnectionStateHelper.getStateName(static_cast(dataSource->state))); 132 | src->setData(src->index(iRow, COLUMN_DATA_STATE), dataSource->state, DataTyp::DataTyp_TypState); 133 | src->setData(src->index(iRow, COLUMN_DATA_STATE), uuid, DataTyp::DataTyp_TypId); 134 | src->setData(src->index(iRow, COLUMN_DATA_REMOTEHOST), dataSource->remoteHost); 135 | src->setData(src->index(iRow, COLUMN_DATA_REMOTEADDRESS), dataSource->remoteAddr); 136 | src->setData(src->index(iRow, COLUMN_DATA_REMOTEPORT), dataSource->remotePort); 137 | src->setData(src->index(iRow, COLUMN_DATA_UID), CUserName::GetUserNameString(dataSource->uid, dataSource->inode == 0)); 138 | src->setData(src->index(iRow, COLUMN_DATA_INODE), QString::number(dataSource->inode)); 139 | src->setData(src->index(iRow, COLUMN_DATA_TIME), tmpTime); 140 | src->setData(src->index(iRow, COLUMN_DATA_COMMAND), dataSource->command); 141 | 142 | dataSource->commandUpdate = false; 143 | dataSource->stateUpdate = false; 144 | } 145 | 146 | } 147 | 148 | void CConnectionsTree::InitConnectonsTree(QTreeView *connView) 149 | { 150 | 151 | connView->setSelectionMode(QAbstractItemView::SingleSelection); 152 | 153 | auto pStandardModel = new QStandardItemModel(0, m_caption.size(), connView); 154 | auto pProxyModel = new CCustomProxyModel(connView); 155 | m_pProxyModel = pProxyModel; 156 | connView->setModel(pProxyModel); 157 | pProxyModel->setSourceModel(pStandardModel); 158 | 159 | //1) adjust column width 160 | QMapIterator tmpCaptionName(m_caption); 161 | while (tmpCaptionName.hasNext()) 162 | { 163 | tmpCaptionName.next(); 164 | pStandardModel->setHeaderData(tmpCaptionName.key(), Qt::Horizontal, tmpCaptionName.value().captionSample()); 165 | } 166 | 167 | tmpCaptionName.toFront(); 168 | while (tmpCaptionName.hasNext()) 169 | { 170 | tmpCaptionName.next(); 171 | connView->resizeColumnToContents(tmpCaptionName.key()); 172 | } 173 | 174 | //2) set name & tooltip 175 | auto index = 0; 176 | tmpCaptionName.toFront(); 177 | while (tmpCaptionName.hasNext()) 178 | { 179 | tmpCaptionName.next(); 180 | pStandardModel->setHeaderData(tmpCaptionName.key(), Qt::Horizontal, tmpCaptionName.value().caption()); 181 | pStandardModel->horizontalHeaderItem(index++)->setToolTip(tmpCaptionName.value().captionToolTip()); 182 | } 183 | 184 | pProxyModel->setDynamicSortFilter(true); 185 | } 186 | 187 | void CConnectionsTree::UpdateIncludeFilter(const QString &value) 188 | { 189 | m_pProxyModel->setFilterRegExpEx(value); 190 | } 191 | 192 | //void CConnectionsTree::SetDataColumnHiden(QTreeView *tree) 193 | //{ 194 | // for(auto idx = 0; idx < COLUMN_DATA_DATA; idx++) 195 | // tree->setColumnHidden(idx, false); 196 | // tree->setColumnHidden(COLUMN_DATA_DATA, true); 197 | //} 198 | 199 | void CConnectionsTree::Save(QWidget *parent) 200 | { 201 | 202 | auto docsLocation = QStandardPaths::standardLocations(QStandardPaths::DocumentsLocation); 203 | auto docPath = (docsLocation.isEmpty()) ? "~/" : QString("%1").arg(docsLocation.first()); 204 | 205 | QStringList filters; 206 | filters << "XML (*.xml)" << "CSV (*.csv)"; 207 | 208 | QFileDialog dialog(parent, QObject::tr("Save as ..."), docPath); 209 | dialog.setAcceptMode(QFileDialog::AcceptSave); 210 | dialog.setNameFilters(filters); 211 | 212 | if (dialog.exec() == QDialog::Accepted && !dialog.selectedFiles().empty()) 213 | { 214 | 215 | auto selectedFilter = dialog.selectedNameFilter(); 216 | auto fileName = dialog.selectedFiles().at(0); 217 | 218 | try 219 | { 220 | 221 | CFileSaveWrapper file; 222 | file.Open(fileName, selectedFilter, parent); 223 | 224 | auto src = qobject_cast(m_pProxyModel->sourceModel()); 225 | if(src == nullptr) 226 | throw std::runtime_error("Error qobject_cast(m_pProxyModel->sourceModel())"); 227 | 228 | for(auto row = 0; row < src->rowCount(); row++) 229 | { 230 | file.ElemStart("r"); 231 | auto colmax = src->columnCount(); 232 | 233 | for(int col = 0; col < colmax; col++) 234 | { 235 | file.ElemStart("c"); 236 | file.ElemVal(src->data(src->index(row, col)).toString()); 237 | file.ElemEnd("c"); 238 | } 239 | file.ElemEnd("r"); 240 | } 241 | 242 | file.Close(); 243 | 244 | } 245 | catch(std::exception &e) 246 | { 247 | QMessageBox::critical(parent, QObject::tr("Save"), e.what(), QMessageBox::Ok); 248 | } 249 | catch(...) 250 | { 251 | QMessageBox::critical(parent, QObject::tr("Save"), QObject::tr("Unexpected exception"), QMessageBox::Ok); 252 | } 253 | } 254 | } 255 | 256 | 257 | 258 | -------------------------------------------------------------------------------- /source/datasource.cpp: -------------------------------------------------------------------------------- 1 | /* This file is part of "TcpView For Linux" - network connections viewer for Linux 2 | * Copyright (C) 2021 chipmunk-sm 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include "datasource.h" 19 | #include 20 | #include 21 | #include 22 | #include "defined.h" 23 | 24 | //#if __cplusplus > 201103L 25 | //using namespace std::chrono_literals; 26 | //#else 27 | //constexpr std::chrono::milliseconds operator "" ms(unsigned long long x_val) 28 | //{ 29 | // return (std::chrono::milliseconds(x_val)); 30 | //} 31 | //#endif 32 | 33 | CDataSource::CDataSource() 34 | { 35 | m_eNetTypeList.insert(std::make_pair(conn_tcp, PROC_NET_TCP)); 36 | m_eNetTypeList.insert(std::make_pair(conn_udp, PROC_NET_UDP)); 37 | m_eNetTypeList.insert(std::make_pair(conn_tcp6, PROC_NET_TCP6)); 38 | m_eNetTypeList.insert(std::make_pair(conn_udp6, PROC_NET_UDP6)); 39 | m_eNetTypeList.insert(std::make_pair(conn_raw, PROC_NET_RAW)); 40 | m_eNetTypeList.insert(std::make_pair(conn_raw6, PROC_NET_RAW6)); 41 | } 42 | 43 | CDataSource::~CDataSource() 44 | { 45 | 46 | if (m_rootModule) 47 | m_rootModule->setAbort(); 48 | 49 | m_threadStop = true; 50 | 51 | int32_t timeout = 3000; 52 | while (!m_threadExit && timeout--) 53 | { 54 | //std::this_thread::yield(); 55 | if(!m_threadExit) 56 | std::this_thread::sleep_for(std::chrono::milliseconds(20)); 57 | } 58 | 59 | m_rootModule = nullptr; 60 | 61 | } 62 | 63 | void CDataSource::Init(const std::function &callbackUpdate) 64 | { 65 | 66 | m_callbackUpdate = callbackUpdate; 67 | 68 | if(!m_threadExit) 69 | return; 70 | 71 | m_threadExit = false; 72 | 73 | auto threadBase = [](CDataSource* pThis) 74 | { 75 | 76 | try 77 | { 78 | pThis->m_threadStop = false; 79 | pThis->ThreadMain(); 80 | } 81 | catch(const std::exception &e) 82 | { 83 | //qFatal("CDataSource: %s", e.what()); 84 | } 85 | catch(...) 86 | { 87 | //qFatal("CDataSource: Unexpected exception"); 88 | } 89 | 90 | //qInfo("Shutdown CDataSource thread"); 91 | 92 | pThis->m_threadStop = true; 93 | pThis->m_threadExit = true; 94 | 95 | }; 96 | (std::thread(threadBase, this)).detach(); 97 | } 98 | 99 | void CDataSource::setAbort() 100 | { 101 | if (m_rootModule) 102 | m_rootModule->setAbort(); 103 | 104 | m_threadStop = true; 105 | } 106 | 107 | void CDataSource::ThreadMain() 108 | { 109 | while (!m_threadStop) { 110 | m_updateInProgress = true; 111 | UpdateTable(); 112 | m_updateInProgress = false; 113 | std::this_thread::sleep_for(std::chrono::milliseconds(100)); 114 | } 115 | } 116 | 117 | #ifdef USECONSTFUNCTION 118 | 119 | bool CDataSource::pauseUpdate() const 120 | { 121 | while(m_updateInProgress && !m_pauseUpdate && !m_threadStop) 122 | std::this_thread::sleep_for(std::chrono::milliseconds(16)); 123 | return m_pauseUpdate; 124 | } 125 | 126 | void CDataSource::setPauseUpdate(bool pauseUpdate) 127 | { 128 | while(m_updateInProgress && !m_pauseUpdate && !m_threadStop) 129 | std::this_thread::sleep_for(std::chrono::milliseconds(16)); 130 | m_pauseUpdate = pauseUpdate; 131 | } 132 | 133 | #else 134 | 135 | bool CDataSource::pauseUpdate() 136 | { 137 | const std::lock_guard guard(m_run_update); 138 | return m_pauseUpdate; 139 | } 140 | 141 | void CDataSource::setPauseUpdate(bool pauseUpdate) 142 | { 143 | const std::lock_guard guard(m_run_update); 144 | m_pauseUpdate = pauseUpdate; 145 | } 146 | 147 | #endif 148 | 149 | int CDataSource::timeoutSec() const 150 | { 151 | return m_removeRecordTimeoutSec; 152 | } 153 | 154 | void CDataSource::setTimeoutSec(int timeoutSec) 155 | { 156 | m_removeRecordTimeoutSec = timeoutSec; 157 | } 158 | 159 | bool CDataSource::InitRootLoader(std::string name) 160 | { 161 | if(m_rootModule) 162 | return true; 163 | 164 | auto pause = pauseUpdate(); 165 | setPauseUpdate(true); 166 | 167 | std::shared_ptr tmp_ptr = std::make_shared(-1, name); 168 | if(tmp_ptr->isAbort()) 169 | { 170 | setPauseUpdate(pause); 171 | return false; 172 | } 173 | 174 | m_rootModule = tmp_ptr; 175 | setPauseUpdate(pause); 176 | return true; 177 | } 178 | 179 | bool CDataSource::rootLoaderActive() { 180 | return m_rootModule != nullptr; 181 | } 182 | 183 | void CDataSource::shutdownRootModule() { 184 | if (m_rootModule) { 185 | m_rootModule->setAbort(); 186 | } 187 | } 188 | 189 | void CDataSource::UpdateTable() 190 | { 191 | 192 | if(m_pauseUpdate || m_connectionsListInUse) 193 | return; 194 | 195 | #ifdef USECONSTFUNCTION 196 | 197 | #else 198 | const std::lock_guard guard(m_run_update); 199 | #endif 200 | 201 | 202 | time_t nowtime = time(nullptr); 203 | 204 | /* load socket connections */ 205 | for (const auto& it : m_eNetTypeList) 206 | LoadConnections(it.first, it.second.c_str(), &m_socketList, &m_portServiceNames, nowtime); 207 | 208 | std::map procInodeList; 209 | std::map procCommand; 210 | 211 | if (m_rootModule) 212 | { 213 | m_rootModule->RunClient(&procInodeList, &procCommand); 214 | if (m_rootModule->isAbort()) 215 | m_rootModule = nullptr; 216 | } 217 | 218 | int update = 0; 219 | for (auto it = m_socketList.begin(); it != m_socketList.end(); it++) 220 | { 221 | 222 | DomainNamesResolver(it->second); 223 | 224 | SocketInfo *sinf = &it->second; 225 | 226 | /* set cleanup flag for old entries in socketList */ 227 | if (nowtime != sinf->last_time) 228 | { 229 | sinf->state = CONNECTION_REMOVED; 230 | sinf->stateUpdate = true; 231 | auto diff = nowtime - sinf->last_time; 232 | if(diff > timeoutSec()) 233 | sinf->deleteItem++; 234 | } 235 | 236 | if(sinf->command[0] == 0 && procCommand.size()) 237 | { 238 | if(LoadCmd( sinf->inode, &procCommand, &procInodeList, sinf->command, sizeof(SocketInfo::command))) 239 | sinf->commandUpdate = true; 240 | } 241 | 242 | if(sinf->stateUpdate || sinf->commandUpdate) 243 | update++; 244 | } 245 | 246 | if(update) 247 | { 248 | m_connectionsListInUse = true; 249 | m_callbackUpdate(); 250 | } 251 | 252 | } 253 | 254 | bool CDataSource::LoadCmd(unsigned long long inode, 255 | std::map *procCommand, 256 | std::map *procInodeList, 257 | char * pBuff, 258 | size_t bufferLen) 259 | { 260 | auto it = procInodeList->find(inode); 261 | if (it == procInodeList->end()) 262 | return false; 263 | 264 | auto pid = it->second; 265 | auto comm = procCommand->find(pid); 266 | if ( comm != procCommand->end() ) 267 | snprintf(pBuff, bufferLen, "(%u) %s", pid, comm->second.c_str()); 268 | else 269 | snprintf(pBuff, bufferLen, "(%u)", pid); 270 | 271 | return true; 272 | } 273 | 274 | void CDataSource::DomainNamesResolver(SocketInfo &socket_info) 275 | { 276 | 277 | if(socket_info.remoteHost[0] != 0) 278 | return; 279 | 280 | if (socket_info.netType == conn_tcp6 || socket_info.netType == conn_udp6 || socket_info.netType == conn_raw6) 281 | { 282 | auto locval = gethostbyaddr(&socket_info.loc6, sizeof(socket_info.loc6), AF_INET6); 283 | strncpy(socket_info.localHost, locval == nullptr ? "*" : locval->h_name, NI_MAXHOST); 284 | 285 | auto remval = gethostbyaddr(&socket_info.rem6, sizeof(socket_info.rem6), AF_INET6); 286 | strncpy(socket_info.remoteHost, remval == nullptr ? "*" : remval->h_name, NI_MAXHOST); 287 | } 288 | else 289 | { 290 | auto locval = gethostbyaddr(&socket_info.loc4, sizeof(socket_info.loc4), AF_INET); 291 | strncpy(socket_info.localHost, locval == nullptr ? "*" : locval->h_name, NI_MAXHOST); 292 | 293 | auto remval = gethostbyaddr(&socket_info.rem4, sizeof(socket_info.rem4), AF_INET); 294 | strncpy(socket_info.remoteHost, remval == nullptr ? "*" : remval->h_name, NI_MAXHOST); 295 | } 296 | } 297 | 298 | void CDataSource::LoadConnections(eNetType netType, 299 | const char * commandLine, 300 | std::unordered_map *pSocketList, 301 | CPortServiceNames *pCPortServiceNames, 302 | const time_t nowtime) 303 | { 304 | 305 | FILE *netstat; 306 | char buffer[1024]; 307 | 308 | if ((netstat = fopen(commandLine, "r")) == nullptr) 309 | return; 310 | 311 | int loadIndex = 0; 312 | 313 | while (fgets(buffer, sizeof(buffer), netstat) != nullptr) 314 | { 315 | 316 | if(loadIndex++ == 0) 317 | continue; // skip header 318 | 319 | if (buffer[0] == 0) 320 | continue; // next connection 321 | 322 | char loc_addr[INET6_ADDRSTRLEN*2] = {0}; 323 | int loc_port = 0; 324 | 325 | char rem_addr[INET6_ADDRSTRLEN*2] = {0}; 326 | int rem_port = 0; 327 | 328 | unsigned int state = static_cast(-1); 329 | unsigned int uid = 0; 330 | unsigned long long inode = 0; 331 | // sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode 332 | // 0: 0100007F:0277 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 374316 1 0000000000000000 100 0 0 10 0 333 | // 1: 00000000:14EB 00000000:0000 0A 00000000:00000000 00:00000000 00000000 102 0 11821 1 0000000000000000 100 0 0 10 0 334 | // 2: 0101007F:0035 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 14305 1 0000000000000000 100 0 0 10 0 335 | // 3: 3500007F:0035 00000000:0000 0A 00000000:00000000 00:00000000 00000000 102 0 11819 1 0000000000000000 100 0 0 10 0 336 | 337 | //kernel 4.8 338 | //tcp 0 1 2 3 4 5 6 7 8 9 10 11 12 13 339 | // 0: 0100007F:0277 00000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 20167 1 ffff95d359afbc00 100 0 0 10 0 340 | // sl local_address rem_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode 341 | 342 | //tcp6 0 1 2 3 4 5 6 7 8 9 10 11 12 13 343 | // 0: 00000000000000000000000001000000:0277 00000000000000000000000000000000:0000 0A 00000000:00000000 00:00000000 00000000 0 0 151787 1 ffff95d35a92b9c0 100 0 0 10 0 344 | // sl local_address remote_address st tx_queue rx_queue tr tm->when retrnsmt uid timeout inode 345 | auto num = sscanf(buffer, 346 | //0 1 2 3 4 5 6 7 8 9 10 11 12 13 347 | "%*d: %64[0-9A-Fa-f]:%X %64[0-9A-Fa-f]:%X %X %*x:%*x %*x:%*x %*x %u %*d %llu\n", 348 | /*1 2*/ 349 | loc_addr, &loc_port, 350 | /*3 4*/ 351 | rem_addr, &rem_port, 352 | /*5*/ 353 | &state, 354 | /*11*/ 355 | &uid, 356 | /*13*/ 357 | &inode); 358 | 359 | if (num != 7) 360 | { 361 | //qWarning("Parser error for:\t %s", buffer); 362 | continue; // next connection 363 | } 364 | 365 | if (inode == 0) 366 | { 367 | //qInfo("Zero inode: %s", buffer); 368 | } 369 | 370 | std::snprintf(buffer, sizeof(buffer),"%s%d%s%d%d",loc_addr, loc_port, rem_addr, rem_port, netType); 371 | std::string keystring(buffer); 372 | 373 | //check for already exist record 374 | auto search = pSocketList->find(keystring); 375 | if(search != pSocketList->end()) 376 | { 377 | search->second.last_time = nowtime; 378 | search->second.stateUpdate = search->second.state != state; 379 | search->second.state = state; 380 | continue; // next connection 381 | } 382 | 383 | //process new record 384 | SocketInfo socket_info; 385 | memset(&socket_info, 0, sizeof(socket_info)); 386 | 387 | socket_info.last_time = nowtime; 388 | socket_info.netType = netType; 389 | socket_info.uid = uid; 390 | socket_info.inode = inode; 391 | socket_info.stateUpdate = true; 392 | socket_info.state = state; 393 | 394 | pCPortServiceNames->getServiceName(loc_port, socket_info.localPort, sizeof(socket_info.localPort), (netType == conn_tcp || netType == conn_tcp6)); 395 | pCPortServiceNames->getServiceName(rem_port, socket_info.remotePort, sizeof(socket_info.remotePort), (netType == conn_tcp || netType == conn_tcp6)); 396 | 397 | if (socket_info.netType == conn_tcp6 || socket_info.netType == conn_udp6 || socket_info.netType == conn_raw6) 398 | { 399 | sscanf(loc_addr, "%08X%08X%08X%08X", &socket_info.loc6.s6_addr32[0], &socket_info.loc6.s6_addr32[1], &socket_info.loc6.s6_addr32[2], &socket_info.loc6.s6_addr32[3]); 400 | inet_ntop(AF_INET6, &socket_info.loc6, socket_info.localAddr, INET6_ADDRSTRLEN); 401 | 402 | sscanf(rem_addr, "%08X%08X%08X%08X", &socket_info.rem6.s6_addr32[0], &socket_info.rem6.s6_addr32[1], &socket_info.rem6.s6_addr32[2], &socket_info.rem6.s6_addr32[3]); 403 | inet_ntop(AF_INET6, &socket_info.rem6, socket_info.remoteAddr, INET6_ADDRSTRLEN); 404 | } 405 | else 406 | { 407 | sscanf(loc_addr, "%X", &(socket_info.loc4.s_addr)); 408 | strncpy(socket_info.localAddr, inet_ntoa(socket_info.loc4), INET6_ADDRSTRLEN); 409 | 410 | sscanf(rem_addr, "%X", &(socket_info.rem4.s_addr)); 411 | strncpy(socket_info.remoteAddr, inet_ntoa(socket_info.rem4), INET6_ADDRSTRLEN); 412 | } 413 | 414 | uuid_generate(socket_info.uuid); 415 | pSocketList->emplace(std::make_pair(keystring, socket_info)); 416 | 417 | } 418 | 419 | fclose(netstat); 420 | 421 | } 422 | 423 | std::unordered_map *CDataSource::GetConnectionsList() 424 | { 425 | return &m_socketList; 426 | } 427 | 428 | void CDataSource::FreeConnectionsList() 429 | { 430 | m_connectionsListInUse = false; 431 | } 432 | 433 | 434 | 435 | 436 | -------------------------------------------------------------------------------- /source/rootmodule.cpp: -------------------------------------------------------------------------------- 1 | /* This file is part of "TcpView For Linux" - network connections viewer for Linux 2 | * Copyright (C) 2021 chipmunk-sm 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include "rootmodule.h" 19 | 20 | #include "defined.h" 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | 31 | //Read-only, without O_NONBLOCK: open blocks until another process opens the FIFO for writing. 32 | //Write-only, without O_NONBLOCK: open blocks until another process opens the FIFO for reading. 33 | //Read-only, with O_NONBLOCK: open returns immediately. 34 | //Write-only, with O_NONBLOCK: open returns an error with errno set to ENXIO 35 | //unless another process has the FIFO open for reading. 36 | 37 | #define MIN(a,b) (((a)<(b))?(a):(b)) 38 | #define MAX(a,b) (((a)>(b))?(a):(b)) 39 | 40 | CRootModule::CRootModule(__pid_t processId, std::string) 41 | : m_syncCounter(0) 42 | , m_processId(processId) 43 | , m_fifoNameSrv("/tmp/TcpView_2021") 44 | , m_fifoNameSrvRun(m_fifoNameSrv + "_run") 45 | , m_fifoSrv(-1) 46 | , m_abort(false) 47 | { 48 | 49 | int timeout = TIMEOUT_SERVER_START; 50 | 51 | auto serverMode = m_processId > 0;//server - child process with root access 52 | if (!serverMode) 53 | { 54 | 55 | unlink(m_fifoNameSrv.c_str()); 56 | 57 | if (mkfifo(m_fifoNameSrv.c_str(), S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) == -1) 58 | { 59 | setAbort(); 60 | return; 61 | } 62 | 63 | if ((m_fifoSrv = open(m_fifoNameSrv.c_str(), O_RDONLY|O_TRUNC|O_NONBLOCK)) <= 0) 64 | { 65 | unlink(m_fifoNameSrv.c_str()); 66 | setAbort(); 67 | } 68 | } 69 | else 70 | { 71 | 72 | unlink(m_fifoNameSrvRun.c_str()); 73 | if (mkfifo(m_fifoNameSrvRun.c_str(), S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) == -1) 74 | { 75 | setAbort(); 76 | return; 77 | } 78 | chmod(m_fifoNameSrvRun.c_str(), S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); 79 | 80 | 81 | // chmod(m_fifoNameSrv.c_str(), S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH); 82 | 83 | while ((m_fifoSrv = open(m_fifoNameSrv.c_str(), O_WRONLY|O_TRUNC)) <= 0) 84 | { 85 | if(!timeout--) 86 | break; 87 | std::this_thread::sleep_for(std::chrono::milliseconds(100)); 88 | } 89 | 90 | if (m_fifoSrv <= 0) 91 | setAbort(); 92 | } 93 | } 94 | 95 | CRootModule::~CRootModule() 96 | { 97 | setAbort(); 98 | } 99 | 100 | void CRootModule::RunClient( 101 | std::map *pProcInodeList, 102 | std::map *procCommand) 103 | { 104 | 105 | if (m_fifoSrv <= 0 || isAbort()) 106 | { 107 | setAbort(); 108 | return; 109 | } 110 | 111 | while(true && !isAbort()) 112 | { 113 | auto retv = ReadFifo(m_fifoSrv, &m_buffer); 114 | if (retv <= 0) 115 | return; 116 | 117 | // Ensure buffer is large enough and properly sized for the read data 118 | if (m_buffer.size() < sizeof(ItemInfo) + _POSIX_PATH_MAX + 1) 119 | m_buffer.resize(sizeof(ItemInfo) + _POSIX_PATH_MAX + 1); 120 | 121 | auto const itemInf = reinterpret_cast(m_buffer.data()); 122 | if (itemInf->startcode1 != DEF_STARTCODE || itemInf->startcode1 != DEF_STARTCODE) 123 | { 124 | setAbort(); 125 | return; 126 | } 127 | 128 | switch (itemInf->command) 129 | { 130 | case ItemType_ERROR: 131 | default: 132 | std::this_thread::sleep_for(std::chrono::milliseconds(100)); 133 | continue; 134 | case ItemType_none: 135 | continue; 136 | case ItemType_end: 137 | return; 138 | case ItemType_inode: 139 | { 140 | auto inodePtr = reinterpret_cast(itemInf + 1); 141 | 142 | for (unsigned int inodeInd = 0; inodeInd < itemInf->dataCount/sizeof(unsigned int); inodeInd++) 143 | pProcInodeList->insert(std::pair(*inodePtr++, itemInf->procId)); 144 | 145 | continue; 146 | } 147 | case ItemType_cmd: 148 | { 149 | if (itemInf->dataCount > 0 ) 150 | { 151 | auto dataPtr = reinterpret_cast(itemInf + 1); 152 | 153 | if(itemInf->dataCount > _POSIX_PATH_MAX) 154 | itemInf->dataCount = _POSIX_PATH_MAX; 155 | 156 | dataPtr[itemInf->dataCount - 1] = 0; 157 | procCommand->insert(std::pair(itemInf->procId, std::string(dataPtr))); 158 | } 159 | continue; 160 | } 161 | } 162 | } 163 | } 164 | 165 | bool CRootModule::isAbort() const 166 | { 167 | return m_abort; 168 | } 169 | 170 | void CRootModule::setAbort() 171 | { 172 | if (m_fifoSrv) 173 | { 174 | close(m_fifoSrv); 175 | m_fifoSrv = -1; 176 | } 177 | 178 | // auto serverMode = m_processId > 0;//server - child process with root access 179 | // if (!serverMode) 180 | unlink(m_fifoNameSrv.c_str()); 181 | unlink(m_fifoNameSrvRun.c_str()); 182 | 183 | m_abort = true; 184 | } 185 | 186 | void CRootModule::RunServer() 187 | { 188 | char bufferPtr[sizeof(ItemInfo)]; 189 | auto const inf = reinterpret_cast(bufferPtr); 190 | inf->dataCount = 0; 191 | inf->startcode1 = DEF_STARTCODE; 192 | inf->startcode2 = DEF_STARTCODE; 193 | 194 | inf->procId = 0; 195 | auto bActive = true; 196 | while (bActive) 197 | { 198 | inf->command = ItemType_none; 199 | if (!WriteFifo(m_fifoSrv, bufferPtr, sizeof(ItemInfo))) 200 | break; 201 | 202 | struct dirent *ent; 203 | auto dir = opendir(PROC_PATH); 204 | while (( ent = readdir(dir) )) 205 | { 206 | if ((*ent->d_name < '0') || (*ent->d_name> '9')) 207 | continue; 208 | auto procId = strtoul(ent->d_name, nullptr, 0); 209 | if (!LoadProcessInodeList(static_cast(procId), m_fifoSrv)) 210 | { 211 | bActive = false; 212 | break; 213 | } 214 | } 215 | 216 | closedir(dir); 217 | 218 | if (!bActive) 219 | break; 220 | 221 | inf->command = ItemType_end; 222 | if (!WriteFifo(m_fifoSrv, bufferPtr, sizeof(ItemInfo))) 223 | break; 224 | 225 | } // while(bActive) 226 | 227 | setAbort(); 228 | 229 | } 230 | 231 | bool CRootModule::LoadProcessInodeList(unsigned int pid, int fifoSrv) 232 | { 233 | 234 | int retCount = 0; 235 | char bufferPtr[_POSIX_PATH_MAX + sizeof(ItemInfo) + 1]; 236 | auto bufferSize = sizeof(bufferPtr); 237 | snprintf(bufferPtr, bufferSize, PROC_PATH_FD, pid); 238 | 239 | auto fddir = opendir (bufferPtr); 240 | if (fddir == nullptr) 241 | return true; 242 | 243 | auto const inf = reinterpret_cast(bufferPtr); 244 | inf->procId = pid; 245 | inf->command = ItemType_inode; 246 | inf->dataCount = 0; 247 | inf->startcode1 = DEF_STARTCODE; 248 | inf->startcode2 = DEF_STARTCODE; 249 | 250 | auto dataptr = reinterpret_cast(inf + 1); 251 | 252 | struct dirent *result; 253 | while ((result = readdir(fddir)) != nullptr) 254 | { 255 | if (result->d_type != DT_LNK) 256 | continue; 257 | 258 | char pathBuf[_POSIX_PATH_MAX]; 259 | auto retl = snprintf(pathBuf, sizeof(pathBuf), PROC_PATH_FD2, pid, result->d_name); 260 | if (retl < 1) 261 | continue; 262 | 263 | char tmpBuf[_POSIX_PATH_MAX]; 264 | memset(tmpBuf, 0, sizeof(tmpBuf)); 265 | auto retlen = readlink(pathBuf, tmpBuf, sizeof(tmpBuf) - 1); 266 | if ( (retlen < 4) || retlen > ssize_t(sizeof(tmpBuf) - 1) ) 267 | continue; 268 | 269 | tmpBuf[retlen] = 0x0; 270 | 271 | auto inode = GetSocketFromNameTypeA(tmpBuf, static_cast(retlen)); 272 | if ( inode <= 0 ) 273 | inode = GetSocketFromNameTypeB(tmpBuf, static_cast(retlen)); 274 | 275 | if ( inode > 0 ) 276 | { 277 | retCount++; 278 | dataptr[inf->dataCount++] = inode; 279 | if(inf->dataCount >= (_POSIX_PATH_MAX / sizeof(dataptr[0]) - 1) ) 280 | { 281 | inf->dataCount *= sizeof(dataptr[0]); 282 | if(!WriteFifo(fifoSrv, bufferPtr, sizeof(ItemInfo) + inf->dataCount)) 283 | { 284 | closedir(fddir); 285 | return false; 286 | } 287 | inf->dataCount = 0; 288 | } 289 | } 290 | } 291 | 292 | closedir(fddir); 293 | 294 | if (inf->dataCount > 0) 295 | { 296 | inf->dataCount *= sizeof(dataptr[0]); 297 | if (!WriteFifo(fifoSrv, bufferPtr, sizeof(ItemInfo) + inf->dataCount)) 298 | return false; 299 | } 300 | 301 | if (retCount) 302 | GetCommandString(pid, fifoSrv); 303 | 304 | return true; 305 | 306 | } 307 | 308 | unsigned int CRootModule::GetSocketFromNameTypeA(const char *buf, size_t strLen) 309 | { 310 | const char keyA[] = "socket:["; 311 | const size_t keyALen = sizeof(keyA) - 1; 312 | 313 | if (strLen < keyALen + 2) 314 | return 0; 315 | 316 | if (memcmp(buf, keyA, keyALen) != 0) 317 | return 0; 318 | 319 | if (buf[strLen - 1] != ']') 320 | return 0; 321 | 322 | const char *inodeStr = buf + keyALen; 323 | char *endP = nullptr; 324 | errno = 0; 325 | 326 | auto inodeVal = static_cast(strtoul(inodeStr, &endP, 0)); 327 | 328 | if (endP == (buf+strLen-1) && errno == 0) 329 | return inodeVal; 330 | 331 | return 0; 332 | } 333 | 334 | unsigned int CRootModule::GetSocketFromNameTypeB(const char *buf, size_t strLen) 335 | { 336 | const char keyB[] = "[0000]:"; 337 | const size_t keyBLen = sizeof(keyB) - 1; 338 | 339 | if (strLen < keyBLen + 1) 340 | return 0; 341 | 342 | if (memcmp(buf, keyB, keyBLen) != 0) 343 | return 0; 344 | 345 | const char *inodeStr = buf + keyBLen; 346 | char *endP = nullptr; 347 | errno = 0; 348 | 349 | auto inodeVal = static_cast(strtoul(inodeStr, &endP, 0)); 350 | 351 | if (endP == (buf+strLen) && errno == 0) 352 | return inodeVal; 353 | 354 | return 0; 355 | } 356 | 357 | void CRootModule::GetCommandString(unsigned int pid, int fifoSrv) 358 | { 359 | 360 | char bufferPtr[_POSIX_PATH_MAX + sizeof(ItemInfo) + 1]; 361 | auto bufferSize = sizeof(bufferPtr); 362 | 363 | snprintf(bufferPtr, bufferSize, PROC_PATH_CMD, pid); 364 | 365 | auto fd = fopen( bufferPtr, "r" ); 366 | if (fd == nullptr) 367 | return; 368 | 369 | auto const inf = reinterpret_cast(bufferPtr); 370 | inf->procId = pid; 371 | inf->command = ItemType_cmd; 372 | inf->dataCount = 0; 373 | inf->startcode1 = DEF_STARTCODE; 374 | inf->startcode2 = DEF_STARTCODE; 375 | 376 | auto dataPtr = reinterpret_cast(inf + 1); 377 | int c = EOF; 378 | while ((c = fgetc(fd)) != EOF && inf->dataCount < (_POSIX_PATH_MAX - 1)) 379 | { 380 | *dataPtr++ = (static_cast(c) == '\0' || 381 | static_cast(c) == '\t' || 382 | static_cast(c) == '\n' || 383 | static_cast(c) == '\r' ) ? ' ' : static_cast(c); 384 | inf->dataCount++; 385 | } 386 | 387 | fclose( fd ); 388 | 389 | if (inf->dataCount < 1) 390 | return; 391 | 392 | *dataPtr = '\0'; 393 | inf->dataCount++; 394 | 395 | WriteFifo(fifoSrv, bufferPtr, inf->dataCount + sizeof(ItemInfo)); 396 | 397 | } 398 | 399 | bool CRootModule::WriteFifo(int fifo, const char *pBuffer, size_t size) 400 | { 401 | while(size > 0) 402 | { 403 | auto written = write(fifo, pBuffer, size); 404 | if (written == static_cast(-1)) 405 | { 406 | if (errno == EINTR) 407 | continue; 408 | return false; 409 | } 410 | pBuffer += written; 411 | size -= static_cast(written); 412 | } 413 | return true; 414 | } 415 | 416 | int CRootModule::ReadFifo(int fifo, std::vector *pBuffer) 417 | { 418 | // Ensure buffer is large enough for the initial read 419 | if (pBuffer->size() < sizeof(ItemInfo) + _POSIX_PATH_MAX + 1) 420 | pBuffer->resize(sizeof(ItemInfo) + _POSIX_PATH_MAX + 1); 421 | 422 | auto bufferPtr = pBuffer->data(); 423 | auto inf = reinterpret_cast(bufferPtr); 424 | inf->command = ItemType_ERROR; 425 | inf->startcode1 = 0; 426 | inf->startcode2 = 0; 427 | 428 | int readFifoAttempt = 25; 429 | int output = 0; 430 | 431 | while (readFifoAttempt && !isAbort()) 432 | { 433 | auto readRes = read(fifo, bufferPtr + output, sizeof(ItemInfo) - static_cast(output)); 434 | if (readRes == static_cast(-1)) 435 | { 436 | if (!isAbort() && errno == EINTR) 437 | continue; 438 | return -1; 439 | } 440 | 441 | output += readRes; 442 | 443 | if (output < static_cast(sizeof(ItemInfo))) 444 | { 445 | if(readRes == 0) 446 | { 447 | readFifoAttempt--; 448 | std::this_thread::sleep_for(std::chrono::milliseconds(200)); 449 | } 450 | continue; 451 | } 452 | 453 | if (inf->startcode1 == DEF_STARTCODE && inf->startcode2 == DEF_STARTCODE) 454 | break; 455 | 456 | memmove(bufferPtr, bufferPtr + 1, static_cast(output)); 457 | output--; 458 | 459 | } 460 | 461 | switch (inf->command) 462 | { 463 | case ItemType_cmd: 464 | case ItemType_inode: 465 | break; 466 | default: 467 | case ItemType_none: 468 | case ItemType_end: 469 | return output; 470 | } 471 | 472 | if(inf->dataCount > _POSIX_PATH_MAX) 473 | inf->dataCount = _POSIX_PATH_MAX; 474 | 475 | // Ensure buffer is large enough for additional data 476 | if (pBuffer->size() < output + inf->dataCount) 477 | pBuffer->resize(output + inf->dataCount); 478 | 479 | bufferPtr = pBuffer->data(); // Re-acquire pointer after possible resize 480 | 481 | auto toread = inf->dataCount; 482 | while (toread > 0) 483 | { 484 | auto readRes = read(fifo, bufferPtr + output, toread); 485 | if (readRes == static_cast(-1)) 486 | { 487 | if (errno == EINTR) 488 | continue; 489 | return -1; 490 | } 491 | output += readRes; 492 | toread -= readRes; 493 | } 494 | return output; 495 | } 496 | -------------------------------------------------------------------------------- /source/configdialog.cpp: -------------------------------------------------------------------------------- 1 | /* This file is part of "TcpView For Linux" - network connections viewer for Linux 2 | * Copyright (C) 2021 chipmunk-sm 3 | * 4 | * This program is free software: you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation, either version 3 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program. If not, see . 16 | */ 17 | 18 | #include "configdialog.h" 19 | #include "ccfontsize.h" 20 | 21 | #include 22 | #include 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #define PROP_CLRFOREGROUND "clrForeground" 38 | #define PROP_CLRBACKGROUND "clrBackground" 39 | #define PROP_CLRLABEL "clrLabel" 40 | 41 | ConfigDialog::ConfigDialog(const std::function &callbackUpdate, const std::function &callbackClose, QWidget *parent) 42 | : QDialog(parent) { 43 | 44 | m_callbackUpdate = std::move(callbackUpdate); 45 | m_callbackClose = std::move(callbackClose); 46 | 47 | CCFontSize::changeFontSize(0.0, this); 48 | 49 | setWindowTitle(tr("Settings")); 50 | setSizeGripEnabled(true); 51 | 52 | auto verticalLayout = new QVBoxLayout(this); 53 | 54 | // *** LABEL ABOUT 55 | { 56 | auto label = new QLabel(this); 57 | label->setOpenExternalLinks(true); 58 | label->setText(tr("\n" 59 | "\n" 60 | "\n" 61 | "Copyright (C) chipmunk-sm
\n" 62 | "https://github.com/chipmunk-sm/\n" 63 | "\n" 64 | "")); 65 | verticalLayout->addWidget(label); 66 | } 67 | 68 | // *** QScrollArea for Color Group Box 69 | { 70 | m_scrollArea_color = new QScrollArea(this); 71 | m_scrollArea_color->setWidgetResizable(true); 72 | m_scrollArea_color->setSizeAdjustPolicy(QAbstractScrollArea::AdjustToContentsOnFirstShow); 73 | 74 | verticalLayout->addWidget(m_scrollArea_color); 75 | 76 | auto verticalLayout_2 = new QVBoxLayout(m_scrollArea_color); 77 | auto groupBox = new QGroupBox(m_scrollArea_color); 78 | groupBox->setTitle(tr("Color")); 79 | 80 | auto gridLayout_color = new QGridLayout(groupBox); 81 | verticalLayout_2->addWidget(groupBox); 82 | 83 | m_scrollArea_color->setWidget(groupBox); 84 | m_layout_color = gridLayout_color; 85 | } 86 | 87 | // *** Color Group Box Items 88 | int ind = 0; 89 | for (const auto &item : m_ConnectionStateHelper.getArray()) { 90 | 91 | if (item.first == 0) 92 | continue; 93 | 94 | auto colorLabel = new QLabel(item.second.name); 95 | colorLabel->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter); 96 | m_layout_color->addWidget(colorLabel, ind, 0); 97 | colorLabel->setProperty(PROP_CLRLABEL, QVariant(item.first)); 98 | setLabelColor(item.second.foreground, item.second.background, colorLabel); 99 | 100 | auto colorFButton = new QPushButton(tr("Foreground")); 101 | m_layout_color->addWidget(colorFButton, ind, 1); 102 | connect(colorFButton, &QPushButton::clicked, this, &ConfigDialog::onClick); 103 | colorFButton->setProperty(PROP_CLRFOREGROUND, QVariant(item.first)); 104 | 105 | auto colorBButton = new QPushButton(tr("Background")); 106 | m_layout_color->addWidget(colorBButton, ind, 2); 107 | connect(colorBButton, &QPushButton::clicked, this, &ConfigDialog::onClick); 108 | colorBButton->setProperty(PROP_CLRBACKGROUND, QVariant(item.first)); 109 | 110 | ind++; 111 | } 112 | 113 | // Reset 114 | { 115 | auto resetButton = new QPushButton(tr("Reset color")); 116 | m_layout_color->addWidget(resetButton, ind, 0, 1, 3); 117 | connect(resetButton, &QPushButton::clicked, this, &ConfigDialog::onReset); 118 | } 119 | // separator 120 | { 121 | ind++; 122 | auto line = new QFrame(this); 123 | line->setFrameShape(QFrame::HLine); 124 | line->setFrameShadow(QFrame::Sunken); 125 | m_layout_color->addWidget(line, ind, 0, 1, 3); 126 | } 127 | // Color BW 128 | { 129 | ind++; 130 | auto wbColorButton = new QPushButton(tr("Color - B && W")); 131 | m_layout_color->addWidget(wbColorButton, ind, 0, 1, 3); 132 | connect(wbColorButton, &QPushButton::clicked, this, &ConfigDialog::onWbColor); 133 | } 134 | // Color WB 135 | { 136 | ind++; 137 | auto bwColorButton = new QPushButton(tr("Color - W && B")); 138 | m_layout_color->addWidget(bwColorButton, ind, 0, 1, 3); 139 | connect(bwColorButton, &QPushButton::clicked, this, &ConfigDialog::onBwColor); 140 | } 141 | // separator 142 | { 143 | ind++; 144 | auto line = new QFrame(this); 145 | line->setFrameShape(QFrame::HLine); 146 | line->setFrameShadow(QFrame::Sunken); 147 | m_layout_color->addWidget(line, ind, 0, 1, 3); 148 | } 149 | // Color viewport background 150 | { 151 | ind++; 152 | auto backgroundButton = new QPushButton(tr("Table - set background color")); 153 | m_layout_color->addWidget(backgroundButton, ind, 0, 1, 3); 154 | connect(backgroundButton, &QPushButton::clicked, this, &ConfigDialog::onBackgroundColor); 155 | } 156 | // Color Reset viewport background 157 | { 158 | ind++; 159 | auto backgroundButton = new QPushButton(tr("Table - set default background")); 160 | m_layout_color->addWidget(backgroundButton, ind, 0, 1, 3); 161 | connect(backgroundButton, &QPushButton::clicked, this, &ConfigDialog::onDefaultBackgroundColor); 162 | } 163 | // separator 164 | { 165 | ind++; 166 | auto line = new QFrame(this); 167 | line->setFrameShape(QFrame::HLine); 168 | line->setFrameShadow(QFrame::Sunken); 169 | m_layout_color->addWidget(line, ind, 0, 1, 3); 170 | } 171 | 172 | 173 | auto pObj1 = this; 174 | pObj1->grabGesture(Qt::PinchGesture); 175 | //pObj1->grabGesture(Qt::PanGesture); 176 | //pObj1->grabGesture(Qt::SwipeGesture); 177 | 178 | auto pObj = m_scrollArea_color; 179 | //setHorizontalScrollMode(QAbstractItemView::ScrollPerPixel); 180 | //setVerticalScrollMode(QAbstractItemView::ScrollPerPixel); 181 | 182 | QScroller::grabGesture(pObj, QScroller::LeftMouseButtonGesture); 183 | 184 | QScrollerProperties properties = QScroller::scroller(pObj)->scrollerProperties(); 185 | properties.setScrollMetric(QScrollerProperties::VerticalOvershootPolicy, 186 | QVariant::fromValue(QScrollerProperties::OvershootAlwaysOff)); 187 | properties.setScrollMetric(QScrollerProperties::HorizontalOvershootPolicy, 188 | QVariant::fromValue(QScrollerProperties::OvershootAlwaysOff)); 189 | QScroller::scroller(pObj)->setScrollerProperties(properties); 190 | 191 | #if ((QT_VERSION_MAJOR >= 5 && QT_VERSION_MINOR >= 9) || QT_VERSION_MAJOR >= 6) 192 | 193 | #endif 194 | 195 | readGeometry(); 196 | } 197 | 198 | ConfigDialog::~ConfigDialog() { 199 | m_callbackClose(); 200 | // delete m_ui; 201 | } 202 | 203 | void ConfigDialog::wheelEvent(QWheelEvent *event) { 204 | auto bControl = (event->modifiers() & Qt::ControlModifier) == Qt::ControlModifier; 205 | if (bControl) { 206 | const auto numPixels = event->pixelDelta(); 207 | const auto numDegrees = event->angleDelta(); 208 | 209 | if (!numPixels.isNull()) { 210 | auto fontSize = CCFontSize::changeFontSize((numPixels.y() < 0.0) ? -1 : 1, this); 211 | tooltipText(QString("
Font %1
").arg(static_cast(fontSize))); 212 | } else if (!numDegrees.isNull()) { 213 | auto fontSize = CCFontSize::changeFontSize((numDegrees.y() < 0.0) ? -1 : 1, this); 214 | tooltipText(QString("
Font %1
").arg(static_cast(fontSize))); 215 | } 216 | m_callbackUpdate(); 217 | event->accept(); 218 | return; 219 | } 220 | QDialog::wheelEvent(event); 221 | } 222 | 223 | bool ConfigDialog::event(QEvent *event) { 224 | if (event->type() == QEvent::Gesture) { 225 | auto pGestureEvent = dynamic_cast(event); 226 | if (pGestureEvent) { 227 | auto pPinchGesture = pGestureEvent->gesture(Qt::PinchGesture); 228 | if (pPinchGesture) { 229 | return gestureEventPinch(static_cast(pPinchGesture)); 230 | } 231 | } 232 | } 233 | return QWidget::event(event); 234 | } 235 | 236 | bool ConfigDialog::gestureEventPinch(QPinchGesture *gesture) { 237 | 238 | QPinchGesture::ChangeFlags changeFlags = gesture->changeFlags(); 239 | if ((changeFlags & QPinchGesture::ScaleFactorChanged) == QPinchGesture::ScaleFactorChanged) { 240 | 241 | double scale = 0.0; 242 | double scaleFactor = gesture->scaleFactor() - 1.0; 243 | 244 | if (scaleFactor >= 0.01) 245 | scale = 1; 246 | else if (scaleFactor <= -0.01) 247 | scale = -1; 248 | 249 | if (std::abs(scale) > 0.01) { 250 | auto fontSize = CCFontSize::changeFontSize(scale, this); 251 | tooltipText(QString("
Font %1
").arg(static_cast(fontSize))); 252 | } 253 | } 254 | return true; 255 | } 256 | 257 | void ConfigDialog::tooltipText(const QString &text) { 258 | if (width() < 1 || height() < 1) 259 | return; 260 | 261 | const auto toolTipText = QString("
%1
").arg(text); 262 | auto fm = fontMetrics(); 263 | auto boundingRect = fm.boundingRect(QRect(0, 0, width(), height()), Qt::TextWordWrap, toolTipText); 264 | boundingRect.setWidth(boundingRect.width()); 265 | boundingRect.setHeight(boundingRect.height()); 266 | 267 | auto xPos = width() - boundingRect.width() / 2; 268 | auto yPos = height() - boundingRect.height() / 2; 269 | 270 | if (xPos < 1 || yPos < 1) 271 | return; 272 | 273 | xPos /= 2; 274 | yPos /= 2; 275 | 276 | QToolTip::showText(this->mapToGlobal(QPoint(xPos, yPos)), toolTipText, this); 277 | } 278 | 279 | void ConfigDialog::reloadColor() 280 | { 281 | QLabel *pLabel = nullptr; 282 | for (int idx = 0; idx < m_layout_color->count(); idx++) { 283 | auto item = m_layout_color->itemAt(idx)->widget(); 284 | auto propLab = item->property(PROP_CLRLABEL); 285 | if (propLab.isValid()) { 286 | pLabel = qobject_cast(item); 287 | if (pLabel) { 288 | auto id = static_cast(propLab.toInt()); 289 | setLabelColor(m_ConnectionStateHelper.getStateColor(id, true), m_ConnectionStateHelper.getStateColor(id, false), pLabel); 290 | } 291 | } 292 | } 293 | } 294 | 295 | void ConfigDialog::onClick() { 296 | auto button = qobject_cast(QObject::sender()); 297 | if (!button) 298 | return; 299 | 300 | auto propFr = button->property(PROP_CLRFOREGROUND); 301 | auto propBk = button->property(PROP_CLRBACKGROUND); 302 | auto propVal = propFr.isValid() ? propFr : propBk; 303 | 304 | if (!propVal.isValid()) 305 | return; 306 | 307 | QLabel *pLabel = nullptr; 308 | for (int idx = 0; idx < m_layout_color->count(); idx++) { 309 | auto item = m_layout_color->itemAt(idx)->widget(); 310 | auto propLab = item->property(PROP_CLRLABEL); 311 | if (propLab.isValid()) { 312 | if (propLab == propVal) { 313 | pLabel = qobject_cast(item); 314 | if (pLabel) 315 | break; 316 | } 317 | } 318 | } 319 | 320 | if (!pLabel) 321 | return; 322 | 323 | auto color = QColorDialog::getColor(m_ConnectionStateHelper.getStateColor(static_cast(propVal.toUInt()), propFr.isValid()), this); 324 | if (color.isValid()) { 325 | auto id = static_cast(propVal.toUInt()); 326 | m_ConnectionStateHelper.saveColor(id, color, propFr.isValid()); 327 | setLabelColor(m_ConnectionStateHelper.getStateColor(id, true), m_ConnectionStateHelper.getStateColor(id, false), pLabel); 328 | m_callbackUpdate(); 329 | } 330 | } 331 | 332 | void ConfigDialog::onReset() { 333 | m_ConnectionStateHelper.updatetColor(true); 334 | reloadColor(); 335 | //m_callbackUpdate(); 336 | onDefaultBackgroundColor(); 337 | } 338 | 339 | void ConfigDialog::onBwColor() 340 | { 341 | { 342 | QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName()); 343 | settings.setValue("tree/color", "#000000"); 344 | } 345 | m_ConnectionStateHelper.setBwColor(); 346 | reloadColor(); 347 | m_callbackUpdate(); 348 | } 349 | 350 | void ConfigDialog::onWbColor() 351 | { 352 | { 353 | QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName()); 354 | settings.setValue("tree/color", "#FFFFFF"); 355 | } 356 | m_ConnectionStateHelper.setWbColor(); 357 | reloadColor(); 358 | m_callbackUpdate(); 359 | } 360 | 361 | void ConfigDialog::onBackgroundColor() { 362 | { 363 | QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName()); 364 | auto color = QColorDialog::getColor(QColor(settings.value("tree/color").toString()), this); 365 | if (color.isValid()) { 366 | settings.setValue("tree/color", color.name()); 367 | } 368 | } 369 | m_callbackUpdate(); 370 | } 371 | 372 | void ConfigDialog::onDefaultBackgroundColor() 373 | { 374 | { 375 | QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName()); 376 | settings.setValue("tree/color", ""); 377 | } 378 | m_callbackUpdate(); 379 | } 380 | 381 | void ConfigDialog::setLabelColor(const QColor &frg, const QColor &bkg, QLabel *pLabel) { 382 | const QString clrStyle("QLabel { color: rgb(%1, %2, %3); background-color: rgb(%4, %5, %6); }"); 383 | pLabel->setStyleSheet(clrStyle 384 | .arg(frg.red()) 385 | .arg(frg.green()) 386 | .arg(frg.blue()) 387 | .arg(bkg.red()) 388 | .arg(bkg.green()) 389 | .arg(bkg.blue())); 390 | } 391 | 392 | void ConfigDialog::readGeometry() 393 | { 394 | QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName()); 395 | restoreGeometry(settings.value("settings/geometry").toByteArray()); 396 | } 397 | 398 | void ConfigDialog::closeEvent(QCloseEvent *) 399 | { 400 | QSettings settings(QCoreApplication::organizationName(), QCoreApplication::applicationName()); 401 | settings.setValue("settings/geometry", saveGeometry()); 402 | } 403 | 404 | void ConfigDialog::keyPressEvent(QKeyEvent *event) 405 | { 406 | if (m_scrollArea_color->verticalScrollBar()->isEnabled() && (event->modifiers() & Qt::ControlModifier) == Qt::ControlModifier) 407 | { 408 | m_scrollArea_color->verticalScrollBar()->setEnabled(false); 409 | toolTip(); 410 | } 411 | QWidget::keyPressEvent(event); 412 | } 413 | 414 | void ConfigDialog::keyReleaseEvent(QKeyEvent *event) 415 | { 416 | if(!m_scrollArea_color->verticalScrollBar()->isEnabled() && (event->modifiers() & Qt::ControlModifier) != Qt::ControlModifier) 417 | { 418 | m_scrollArea_color->verticalScrollBar()->setEnabled(true); 419 | QToolTip::hideText(); 420 | } 421 | QWidget::keyReleaseEvent(event); 422 | } 423 | -------------------------------------------------------------------------------- /translations/language_en.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ConfigDialog 6 | 7 | 8 | Settings 9 | 10 | 11 | 12 | 13 | <html> 14 | <head/> 15 | <body> 16 | Copyright (C) chipmunk-sm<br> 17 | <a href="https://github.com/chipmunk-sm/">https://github.com/chipmunk-sm/</a> 18 | </body> 19 | </html> 20 | 21 | 22 | 23 | 24 | Color settings 25 | 26 | 27 | 28 | 29 | Foreground 30 | 31 | 32 | 33 | 34 | Background 35 | 36 | 37 | 38 | 39 | Reset color 40 | 41 | 42 | 43 | 44 | Color - B && W 45 | 46 | 47 | 48 | 49 | Color - W && B 50 | 51 | 52 | 53 | 54 | Table - set background color 55 | 56 | 57 | 58 | 59 | Table - set default background 60 | 61 | 62 | 63 | 64 | MainWindow 65 | 66 | 67 | Filter 68 | 69 | 70 | 71 | 72 | Stop reading new records 73 | 74 | 75 | 76 | 77 | Pause 78 | 79 | 80 | 81 | 82 | Do not cleanup deleted records 83 | 84 | 85 | 86 | 87 | Record 88 | 89 | 90 | 91 | 92 | Copy to Clipboard 93 | 94 | 95 | 96 | 97 | Include word - | 98 | word1|word2|word3 99 | 100 | Word Boundaries - \b 101 | \bWord - start with Word 102 | Word\b - end with Word 103 | \bWord\b - whole words only 104 | 105 | Example. Only UDP and TCP (not TCP6 ot UDP6) 106 | tcp\b|udp\b 107 | 108 | 109 | 110 | 111 | Copy 112 | Colpy 113 | 114 | 115 | 116 | 117 | 118 | 119 | Settings 120 | 121 | 122 | 123 | 124 | Save to XML or CVS 125 | 126 | 127 | 128 | 129 | Save 130 | 131 | 132 | 133 | 134 | <a href="https://github.com/chipmunk-sm/tcpview">https://github.com/chipmunk-sm/tcpview</a> 135 | Sample text Do not translate. 136 | 137 | 138 | 139 | 140 | Display the path of the executable process. (Password required) 141 | 142 | 143 | 144 | 145 | Show processes 146 | 147 | 148 | 149 | 150 | WHOIS - Lookup service to search for the domain name registration information 151 | 152 | 153 | 154 | 155 | whois 156 | 157 | 158 | 159 | 160 | Visible %1 / total %2 161 | 162 | 163 | 164 | 165 | QObject 166 | 167 | 168 | 169 | English 170 | English. 171 | 172 | 173 | 174 | Cannot start module, because 175 | %1 176 | is missing or execution access is denied. 177 | 178 | 179 | 180 | 181 | 182 | 183 | Run as root 184 | 185 | 186 | 187 | 188 | Command 'whois' not found, 189 | but can be installed with: 190 | sudo apt install whois 191 | 192 | 193 | 194 | 195 | Failed run 'whois': 196 | 197 | 198 | 199 | 200 | 201 | Copy 202 | 203 | 204 | 205 | 206 | Copy row 207 | 208 | 209 | 210 | 211 | Restart? 212 | 213 | 214 | 215 | 216 | Root module not found 217 | 218 | 219 | 220 | 221 | Restart 222 | 223 | 224 | 225 | 226 | Protocol 227 | 228 | 229 | 230 | 231 | 232 | tcp6 233 | 234 | 235 | 236 | 237 | Local Host 238 | 239 | 240 | 241 | 242 | Local Address 243 | 244 | 245 | 246 | 247 | 248 | 255.255.255.255 249 | 250 | 251 | 252 | 253 | Local Port 254 | 255 | 256 | 257 | 258 | 259 | 65535 260 | 261 | 262 | 263 | 264 | State 265 | 266 | 267 | 268 | 269 | ESTABLISHED 270 | 271 | 272 | 273 | 274 | Remote Host 275 | 276 | 277 | 278 | 279 | Remote Address 280 | 281 | 282 | 283 | 284 | Remote Port 285 | 286 | 287 | 288 | 289 | User 290 | 291 | 292 | 293 | 294 | 295 | 0000000 296 | 297 | 298 | 299 | 300 | Inode 301 | 302 | 303 | 304 | 305 | Time 306 | 307 | 308 | 309 | 310 | 2017-01-01 00:00:00 311 | 312 | 313 | 314 | 315 | Process path 316 | 317 | 318 | 319 | 320 | tcp 321 | 322 | 323 | 324 | 325 | udp 326 | 327 | 328 | 329 | 330 | udp6 331 | 332 | 333 | 334 | 335 | raw 336 | 337 | 338 | 339 | 340 | raw6 341 | 342 | 343 | 344 | 345 | established 346 | 347 | 348 | 349 | 350 | syn_sent 351 | 352 | 353 | 354 | 355 | syn_recv 356 | 357 | 358 | 359 | 360 | fin_wait1 361 | 362 | 363 | 364 | 365 | fin_wait2 366 | 367 | 368 | 369 | 370 | time_wait 371 | 372 | 373 | 374 | 375 | unconnected 376 | 377 | 378 | 379 | 380 | close_wait 381 | 382 | 383 | 384 | 385 | last_ack 386 | 387 | 388 | 389 | 390 | listen 391 | 392 | 393 | 394 | 395 | closing 396 | 397 | 398 | 399 | 400 | closed 401 | 402 | 403 | 404 | 405 | removed 406 | 407 | 408 | 409 | 410 | Save as ... 411 | 412 | 413 | 414 | 415 | 416 | 417 | 418 | Save 419 | 420 | 421 | 422 | 423 | 424 | Unexpected exception 425 | 426 | 427 | 428 | 429 | 430 | Error: Cannot write file 431 | 432 | 433 | 434 | 435 | 436 | -------------------------------------------------------------------------------- /translations/language_ru.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ConfigDialog 6 | 7 | 8 | Settings 9 | Настройки 10 | 11 | 12 | 13 | <html> 14 | <head/> 15 | <body> 16 | Copyright (C) chipmunk-sm<br> 17 | <a href="https://github.com/chipmunk-sm/">https://github.com/chipmunk-sm/</a> 18 | </body> 19 | </html> 20 | 21 | 22 | 23 | 24 | Color settings 25 | Настройки цвета 26 | 27 | 28 | 29 | Foreground 30 | Цвет текста 31 | 32 | 33 | 34 | Background 35 | Фон 36 | 37 | 38 | 39 | Reset color 40 | Сбросить цвет 41 | 42 | 43 | 44 | Color - B && W 45 | Цвет - B && W 46 | 47 | 48 | 49 | Color - W && B 50 | Цвет - W && B 51 | 52 | 53 | 54 | Table - set background color 55 | Таблица - установить цвет фона 56 | 57 | 58 | 59 | Table - set default background 60 | Таблица - установить фон по умолчанию 61 | 62 | 63 | 64 | MainWindow 65 | 66 | 67 | Filter 68 | Фильтр 69 | 70 | 71 | 72 | Stop reading new records 73 | Остановить чтение новых записей 74 | 75 | 76 | 77 | Pause 78 | Пауза 79 | 80 | 81 | 82 | Do not cleanup deleted records 83 | Не удалять старые записи 84 | 85 | 86 | 87 | Record 88 | Запись 89 | 90 | 91 | 92 | Copy to Clipboard 93 | Копировать строку в буфер обмена 94 | 95 | 96 | 97 | Include word - | 98 | word1|word2|word3 99 | 100 | Word Boundaries - \b 101 | \bWord - start with Word 102 | Word\b - end with Word 103 | \bWord\b - whole words only 104 | 105 | Example. Only UDP and TCP (not TCP6 ot UDP6) 106 | tcp\b|udp\b 107 | 108 | 109 | 110 | 111 | Copy 112 | Colpy 113 | Копировать 114 | 115 | 116 | 117 | 118 | 119 | Settings 120 | Настройки 121 | 122 | 123 | 124 | Save to XML or CVS 125 | Сохранить как XML или CVS 126 | 127 | 128 | 129 | Save 130 | Сохранить 131 | 132 | 133 | 134 | <a href="https://github.com/chipmunk-sm/tcpview">https://github.com/chipmunk-sm/tcpview</a> 135 | 136 | 137 | 138 | 139 | Display the path of the executable process. (Password required) 140 | Показать путь исполняемого процесса. (Требуется пароль) 141 | 142 | 143 | 144 | Show processes 145 | Показывать процессы 146 | 147 | 148 | 149 | WHOIS - Lookup service to search for the domain name registration information 150 | WHOIS информация о регистрации домена 151 | 152 | 153 | 154 | whois 155 | whois 156 | 157 | 158 | 159 | Visible %1 / total %2 160 | Отображено %1 из %2 161 | 162 | 163 | 164 | QObject 165 | 166 | 167 | 168 | English 169 | Русский 170 | 171 | 172 | 173 | Cannot start module, because 174 | %1 175 | is missing or execution access is denied. 176 | Не удается запустить модуль, потому что 177 | %1 178 | отсутствуют или доступ запрещен. 179 | 180 | 181 | 182 | 183 | 184 | Run as root 185 | Запуск с правами root 186 | 187 | 188 | 189 | Command 'whois' not found, 190 | but can be installed with: 191 | sudo apt install whois 192 | Команда whois не найдена, 193 | но можно установить с помощью: 194 | sudo apt install whois 195 | 196 | 197 | 198 | Failed run 'whois': 199 | 200 | Ошибка при запуске 'whois': 201 | 202 | 203 | 204 | 205 | Copy 206 | Копировать 207 | 208 | 209 | 210 | Copy row 211 | Копировать строку 212 | 213 | 214 | 215 | Restart? 216 | Перезапустить? 217 | 218 | 219 | 220 | Root module not found 221 | Root модуль не найден 222 | 223 | 224 | 225 | Restart 226 | Перезапуск 227 | 228 | 229 | 230 | Protocol 231 | Протокол 232 | 233 | 234 | 235 | 236 | tcp6 237 | 238 | 239 | 240 | 241 | Local Host 242 | Локальный хост 243 | 244 | 245 | 246 | Local Address 247 | Локальный адрес 248 | 249 | 250 | 251 | 252 | 255.255.255.255 253 | 254 | 255 | 256 | 257 | Local Port 258 | Локальный порт 259 | 260 | 261 | 262 | 263 | 65535 264 | 265 | 266 | 267 | 268 | State 269 | Состояние 270 | 271 | 272 | 273 | ESTABLISHED 274 | 275 | 276 | 277 | 278 | Remote Host 279 | Удаленный хост 280 | 281 | 282 | 283 | Remote Address 284 | Удаленный адрес 285 | 286 | 287 | 288 | Remote Port 289 | Удаленный порт 290 | 291 | 292 | 293 | User 294 | Владелец 295 | 296 | 297 | 298 | 299 | 0000000 300 | 301 | 302 | 303 | 304 | Inode 305 | Инода 306 | 307 | 308 | 309 | Time 310 | Время 311 | 312 | 313 | 314 | 2017-01-01 00:00:00 315 | 316 | 317 | 318 | 319 | Process path 320 | Исполняемый просесс 321 | 322 | 323 | 324 | tcp 325 | 326 | 327 | 328 | 329 | udp 330 | 331 | 332 | 333 | 334 | udp6 335 | 336 | 337 | 338 | 339 | raw 340 | 341 | 342 | 343 | 344 | raw6 345 | 346 | 347 | 348 | 349 | established 350 | 351 | 352 | 353 | 354 | syn_sent 355 | 356 | 357 | 358 | 359 | syn_recv 360 | 361 | 362 | 363 | 364 | fin_wait1 365 | 366 | 367 | 368 | 369 | fin_wait2 370 | 371 | 372 | 373 | 374 | time_wait 375 | 376 | 377 | 378 | 379 | unconnected 380 | 381 | 382 | 383 | 384 | close_wait 385 | 386 | 387 | 388 | 389 | last_ack 390 | 391 | 392 | 393 | 394 | listen 395 | 396 | 397 | 398 | 399 | closing 400 | 401 | 402 | 403 | 404 | closed 405 | 406 | 407 | 408 | 409 | removed 410 | 411 | 412 | 413 | 414 | Save as ... 415 | Сохранить как... 416 | 417 | 418 | 419 | 420 | 421 | 422 | Save 423 | Сохранить 424 | 425 | 426 | 427 | 428 | Unexpected exception 429 | Неожиданная ошибка 430 | 431 | 432 | 433 | 434 | Error: Cannot write file 435 | 436 | Ошибка: невозможно записать файл 437 | 438 | 439 | 440 | 441 | -------------------------------------------------------------------------------- /translations/language_cs.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ConfigDialog 6 | 7 | 8 | Settings 9 | 10 | 11 | 12 | 13 | <html> 14 | <head/> 15 | <body> 16 | Copyright (C) chipmunk-sm<br> 17 | <a href="https://github.com/chipmunk-sm/">https://github.com/chipmunk-sm/</a> 18 | </body> 19 | </html> 20 | 21 | 22 | 23 | 24 | Color settings 25 | 26 | 27 | 28 | 29 | Foreground 30 | 31 | 32 | 33 | 34 | Background 35 | 36 | 37 | 38 | 39 | Reset color 40 | 41 | 42 | 43 | 44 | Color - B && W 45 | 46 | 47 | 48 | 49 | Color - W && B 50 | 51 | 52 | 53 | 54 | Table - set background color 55 | 56 | 57 | 58 | 59 | Table - set default background 60 | 61 | 62 | 63 | 64 | MainWindow 65 | 66 | 67 | Filter 68 | 69 | 70 | 71 | 72 | Stop reading new records 73 | 74 | 75 | 76 | 77 | Pause 78 | 79 | 80 | 81 | 82 | Do not cleanup deleted records 83 | 84 | 85 | 86 | 87 | Record 88 | 89 | 90 | 91 | 92 | Copy to Clipboard 93 | 94 | 95 | 96 | 97 | Include word - | 98 | word1|word2|word3 99 | 100 | Word Boundaries - \b 101 | \bWord - start with Word 102 | Word\b - end with Word 103 | \bWord\b - whole words only 104 | 105 | Example. Only UDP and TCP (not TCP6 ot UDP6) 106 | tcp\b|udp\b 107 | 108 | 109 | 110 | 111 | Copy 112 | 113 | 114 | 115 | 116 | 117 | 118 | Settings 119 | 120 | 121 | 122 | 123 | Save to XML or CVS 124 | 125 | 126 | 127 | 128 | Save 129 | 130 | 131 | 132 | 133 | <a href="https://github.com/chipmunk-sm/tcpview">https://github.com/chipmunk-sm/tcpview</a> 134 | 135 | 136 | 137 | 138 | Display the path of the executable process. (Password required) 139 | 140 | 141 | 142 | 143 | Show processes 144 | 145 | 146 | 147 | 148 | WHOIS - Lookup service to search for the domain name registration information 149 | 150 | 151 | 152 | 153 | whois 154 | 155 | 156 | 157 | 158 | Visible %1 / total %2 159 | 160 | 161 | 162 | 163 | QObject 164 | 165 | 166 | Cannot start module, because 167 | %1 168 | is missing or execution access is denied. 169 | 170 | 171 | 172 | 173 | 174 | 175 | Run as root 176 | 177 | 178 | 179 | 180 | Command 'whois' not found, 181 | but can be installed with: 182 | sudo apt install whois 183 | 184 | 185 | 186 | 187 | Failed run 'whois': 188 | 189 | 190 | 191 | 192 | 193 | Copy 194 | 195 | 196 | 197 | 198 | Copy row 199 | 200 | 201 | 202 | 203 | Restart? 204 | 205 | 206 | 207 | 208 | Root module not found 209 | 210 | 211 | 212 | 213 | Restart 214 | 215 | 216 | 217 | 218 | Protocol 219 | 220 | 221 | 222 | 223 | 224 | tcp6 225 | 226 | 227 | 228 | 229 | Local Host 230 | 231 | 232 | 233 | 234 | Local Address 235 | 236 | 237 | 238 | 239 | 240 | 255.255.255.255 241 | 242 | 243 | 244 | 245 | Local Port 246 | 247 | 248 | 249 | 250 | 251 | 65535 252 | 253 | 254 | 255 | 256 | State 257 | 258 | 259 | 260 | 261 | ESTABLISHED 262 | 263 | 264 | 265 | 266 | Remote Host 267 | 268 | 269 | 270 | 271 | Remote Address 272 | 273 | 274 | 275 | 276 | Remote Port 277 | 278 | 279 | 280 | 281 | User 282 | 283 | 284 | 285 | 286 | 287 | 0000000 288 | 289 | 290 | 291 | 292 | Inode 293 | 294 | 295 | 296 | 297 | Time 298 | 299 | 300 | 301 | 302 | 2017-01-01 00:00:00 303 | 304 | 305 | 306 | 307 | Process path 308 | 309 | 310 | 311 | 312 | tcp 313 | 314 | 315 | 316 | 317 | udp 318 | 319 | 320 | 321 | 322 | udp6 323 | 324 | 325 | 326 | 327 | raw 328 | 329 | 330 | 331 | 332 | raw6 333 | 334 | 335 | 336 | 337 | established 338 | 339 | 340 | 341 | 342 | syn_sent 343 | 344 | 345 | 346 | 347 | syn_recv 348 | 349 | 350 | 351 | 352 | fin_wait1 353 | 354 | 355 | 356 | 357 | fin_wait2 358 | 359 | 360 | 361 | 362 | time_wait 363 | 364 | 365 | 366 | 367 | unconnected 368 | 369 | 370 | 371 | 372 | close_wait 373 | 374 | 375 | 376 | 377 | last_ack 378 | 379 | 380 | 381 | 382 | listen 383 | 384 | 385 | 386 | 387 | closing 388 | 389 | 390 | 391 | 392 | closed 393 | 394 | 395 | 396 | 397 | removed 398 | 399 | 400 | 401 | 402 | Save as ... 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | Save 411 | 412 | 413 | 414 | 415 | 416 | Unexpected exception 417 | 418 | 419 | 420 | 421 | 422 | Error: Cannot write file 423 | 424 | 425 | 426 | 427 | 428 | 429 | English 430 | Český 431 | 432 | 433 | 434 | -------------------------------------------------------------------------------- /translations/language_de.ts: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | ConfigDialog 6 | 7 | 8 | Settings 9 | 10 | 11 | 12 | 13 | <html> 14 | <head/> 15 | <body> 16 | Copyright (C) chipmunk-sm<br> 17 | <a href="https://github.com/chipmunk-sm/">https://github.com/chipmunk-sm/</a> 18 | </body> 19 | </html> 20 | 21 | 22 | 23 | 24 | Color settings 25 | 26 | 27 | 28 | 29 | Foreground 30 | 31 | 32 | 33 | 34 | Background 35 | 36 | 37 | 38 | 39 | Reset color 40 | 41 | 42 | 43 | 44 | Color - B && W 45 | 46 | 47 | 48 | 49 | Color - W && B 50 | 51 | 52 | 53 | 54 | Table - set background color 55 | 56 | 57 | 58 | 59 | Table - set default background 60 | 61 | 62 | 63 | 64 | MainWindow 65 | 66 | 67 | Filter 68 | 69 | 70 | 71 | 72 | Stop reading new records 73 | 74 | 75 | 76 | 77 | Pause 78 | 79 | 80 | 81 | 82 | Do not cleanup deleted records 83 | 84 | 85 | 86 | 87 | Record 88 | 89 | 90 | 91 | 92 | Copy to Clipboard 93 | 94 | 95 | 96 | 97 | Include word - | 98 | word1|word2|word3 99 | 100 | Word Boundaries - \b 101 | \bWord - start with Word 102 | Word\b - end with Word 103 | \bWord\b - whole words only 104 | 105 | Example. Only UDP and TCP (not TCP6 ot UDP6) 106 | tcp\b|udp\b 107 | 108 | 109 | 110 | 111 | Copy 112 | 113 | 114 | 115 | 116 | 117 | 118 | Settings 119 | 120 | 121 | 122 | 123 | Save to XML or CVS 124 | 125 | 126 | 127 | 128 | Save 129 | 130 | 131 | 132 | 133 | <a href="https://github.com/chipmunk-sm/tcpview">https://github.com/chipmunk-sm/tcpview</a> 134 | 135 | 136 | 137 | 138 | Display the path of the executable process. (Password required) 139 | 140 | 141 | 142 | 143 | Show processes 144 | 145 | 146 | 147 | 148 | WHOIS - Lookup service to search for the domain name registration information 149 | 150 | 151 | 152 | 153 | whois 154 | 155 | 156 | 157 | 158 | Visible %1 / total %2 159 | 160 | 161 | 162 | 163 | QObject 164 | 165 | 166 | Cannot start module, because 167 | %1 168 | is missing or execution access is denied. 169 | 170 | 171 | 172 | 173 | 174 | 175 | Run as root 176 | 177 | 178 | 179 | 180 | Command 'whois' not found, 181 | but can be installed with: 182 | sudo apt install whois 183 | 184 | 185 | 186 | 187 | Failed run 'whois': 188 | 189 | 190 | 191 | 192 | 193 | Copy 194 | 195 | 196 | 197 | 198 | Copy row 199 | 200 | 201 | 202 | 203 | Restart? 204 | 205 | 206 | 207 | 208 | Root module not found 209 | 210 | 211 | 212 | 213 | Restart 214 | 215 | 216 | 217 | 218 | Protocol 219 | 220 | 221 | 222 | 223 | 224 | tcp6 225 | 226 | 227 | 228 | 229 | Local Host 230 | 231 | 232 | 233 | 234 | Local Address 235 | 236 | 237 | 238 | 239 | 240 | 255.255.255.255 241 | 242 | 243 | 244 | 245 | Local Port 246 | 247 | 248 | 249 | 250 | 251 | 65535 252 | 253 | 254 | 255 | 256 | State 257 | 258 | 259 | 260 | 261 | ESTABLISHED 262 | 263 | 264 | 265 | 266 | Remote Host 267 | 268 | 269 | 270 | 271 | Remote Address 272 | 273 | 274 | 275 | 276 | Remote Port 277 | 278 | 279 | 280 | 281 | User 282 | 283 | 284 | 285 | 286 | 287 | 0000000 288 | 289 | 290 | 291 | 292 | Inode 293 | 294 | 295 | 296 | 297 | Time 298 | 299 | 300 | 301 | 302 | 2017-01-01 00:00:00 303 | 304 | 305 | 306 | 307 | Process path 308 | 309 | 310 | 311 | 312 | tcp 313 | 314 | 315 | 316 | 317 | udp 318 | 319 | 320 | 321 | 322 | udp6 323 | 324 | 325 | 326 | 327 | raw 328 | 329 | 330 | 331 | 332 | raw6 333 | 334 | 335 | 336 | 337 | established 338 | 339 | 340 | 341 | 342 | syn_sent 343 | 344 | 345 | 346 | 347 | syn_recv 348 | 349 | 350 | 351 | 352 | fin_wait1 353 | 354 | 355 | 356 | 357 | fin_wait2 358 | 359 | 360 | 361 | 362 | time_wait 363 | 364 | 365 | 366 | 367 | unconnected 368 | 369 | 370 | 371 | 372 | close_wait 373 | 374 | 375 | 376 | 377 | last_ack 378 | 379 | 380 | 381 | 382 | listen 383 | 384 | 385 | 386 | 387 | closing 388 | 389 | 390 | 391 | 392 | closed 393 | 394 | 395 | 396 | 397 | removed 398 | 399 | 400 | 401 | 402 | Save as ... 403 | 404 | 405 | 406 | 407 | 408 | 409 | 410 | Save 411 | 412 | 413 | 414 | 415 | 416 | Unexpected exception 417 | 418 | 419 | 420 | 421 | 422 | Error: Cannot write file 423 | 424 | 425 | 426 | 427 | 428 | 429 | English 430 | Deutsch 431 | 432 | 433 | 434 | --------------------------------------------------------------------------------