20210429のLinuxに関する記事は6件です。

WSL2で躓いたときに読む記事

WSL2に躓いたときの参考資料です。 ポートフォワーディングする方法 ~/.wslconfigのファイルを追加し、下記の内容を記述することでポートフォワーディングが可能になる。 [wsl2] localhostForwarding=true windows側でシャットダウン⇒再起動する。 wsl.exe --shutdown ブラウザの動作確認に使用したかっただけなので、近日リリース予定のGUIに対応したWSLのWSLgでも良いと思います。 Microsoft WSLg説明ページ ※プレビュー版はWindows 10 Insiders preview build 21364でリリース済み
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

liunx conntrackコマンドがフローデータを表示できない

問題 linux conntrackコマンドを実行すると、フローデータを表示できない。 現象 <1>Terminal 1 ( http requestを出します。) admin@ip-172-31-8-4:~$ curl yahoo.co.jp <HTML> <HEAD> <TITLE>Document Has Moved</TITLE> </HEAD> <BODY BGCOLOR="white" FGCOLOR="black"> <H1>Document Has Moved</H1> <HR> <FONT FACE="Helvetica,Arial"><B> Description: The document you requested has moved to a new location. The new location is "https://www.yahoo.co.jp/". </B></FONT> <HR> </BODY> admin@ip-172-31-8-4:~$ <2> Terminal 2 (TCP connectionを監視しますが、データなし) admin@ip-172-31-8-4:~$ sudo conntrack -L conntrack v1.4.5 (conntrack-tools): 0 flow entries have been shown. admin@ip-172-31-8-4:~$ sudo conntrack -E ^Cconntrack v1.4.5 (conntrack-tools): 0 flow events have been shown. admin@ip-172-31-8-4:~$ 原因と解決策 Conntrack only becomes active if your iptables or nftables ruleset has at least one conntrack-based rule (e.g. nftables ct or iptables -m state, or a NAT/masquerade rule, or possibly -j REJECT), otherwise its conntrack_ops are unregistered – most likely to avoid the extra resource usage. sudo iptables -A FORWARD -m conntrack --ctstate INVALID -j DROP 又は、 sudo iptables -A INPUT -m state --state established,related -j ACCEPT 再度確認して、結果が出てくるようになりました。 admin@ip-172-31-8-4:~$ sudo conntrack -E [NEW] udp 17 30 src=172.31.8.4 dst=172.31.0.2 sport=38551 dport=53 [UNREPLIED] src=172.31.0.2 dst=172.31.8.4 sport=53 dport=38551 [UPDATE] udp 17 30 src=172.31.8.4 dst=172.31.0.2 sport=38551 dport=53 src=172.31.0.2 dst=172.31.8.4 sport=53 dport=38551 [UPDATE] udp 17 179 src=172.31.8.4 dst=172.31.0.2 sport=38551 dport=53 src=172.31.0.2 dst=172.31.8.4 sport=53 dport=38551 [ASSURED] [NEW] tcp 6 120 SYN_SENT src=172.31.8.4 dst=183.79.135.206 sport=52250 dport=80 [UNREPLIED] src=183.79.135.206 dst=172.31.8.4 sport=80 dport=52250 [UPDATE] tcp 6 60 SYN_RECV src=172.31.8.4 dst=183.79.135.206 sport=52250 dport=80 src=183.79.135.206 dst=172.31.8.4 sport=80 dport=52250 [UPDATE] tcp 6 432000 ESTABLISHED src=172.31.8.4 dst=183.79.135.206 sport=52250 dport=80 src=183.79.135.206 dst=172.31.8.4 sport=80 dport=52250 [ASSURED] [UPDATE] tcp 6 119 FIN_WAIT src=172.31.8.4 dst=183.79.135.206 sport=52250 dport=80 src=183.79.135.206 dst=172.31.8.4 sport=80 dport=52250 [ASSURED] [UPDATE] tcp 6 29 LAST_ACK src=172.31.8.4 dst=183.79.135.206 sport=52250 dport=80 src=183.79.135.206 dst=172.31.8.4 sport=80 dport=52250 [ASSURED] [UPDATE] tcp 6 119 TIME_WAIT src=172.31.8.4 dst=183.79.135.206 sport=52250 dport=80 src=183.79.135.206 dst=172.31.8.4 sport=80 dport=52250 [ASSURED] ^Cconntrack v1.4.5 (conntrack-tools): 9 flow events have been shown. admin@ip-172-31-8-4:~$ sudo conntrack -L tcp 6 299 ESTABLISHED src=172.31.11.10 dst=172.31.8.4 sport=40526 dport=22 src=172.31.8.4 dst=172.31.11.10 sport=22 dport=40526 [ASSURED] mark=0 use=1 tcp 6 102 TIME_WAIT src=172.31.8.4 dst=183.79.135.206 sport=52250 dport=80 src=183.79.135.206 dst=172.31.8.4 sport=80 dport=52250 [ASSURED] mark=0 use=1 icmp 1 8 src=172.31.8.4 dst=172.31.11.10 type=8 code=0 id=1581 src=172.31.11.10 dst=172.31.8.4 type=0 code=0 id=1581 mark=0 use=1 tcp 6 431982 ESTABLISHED src=172.31.11.10 dst=172.31.8.4 sport=40524 dport=22 src=172.31.8.4 dst=172.31.11.10 sport=22 dport=40524 [ASSURED] mark=0 use=1 udp 17 161 src=172.31.8.4 dst=172.31.0.2 sport=38551 dport=53 src=172.31.0.2 dst=172.31.8.4 sport=53 dport=38551 [ASSURED] mark=0 use=1 conntrack v1.4.5 (conntrack-tools): 5 flow entries have been shown. admin@ip-172-31-8-4:~$
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

軽量 Linux ディストリ

antiX Linux https://antixlinux.com/ http://ftp.riken.jp/Linux/mxlinux-iso/ANTIX/Final/antiX-19/?C=M;O=A 軽いが、以下画面で2分は待たされる。 antiX-19.3_x64-base.iso icewm + ROX filer snapshot機能 日本語入力 apt install -y \ fcitx fcitx-mozc \ zenity \ im-config \ fcitx-config-gtk im-config fcitx-config-gtk3 MX Linux 公式 日本語化版 - ライブCDの部屋 MX-19.4.1_x64 "ahs" : 最新のハードウェアサポート (VirtualBoxでは起動途中で止まった。) user / pass = demo / root 日本語入力 apt install -y \ --install-recommends \ fcitx fcitx-mozc im-config fcitx-config-gtk3 NNLinux NNLinux Debian10, Xfce4 ベース。mozcなど入っている インストールには 10GB の空きが必要。 PuppyLinux64 9.5 (Ubuntu20.04ベース) 公式 (英語版) fossapup64-9.5.iso 日本語化パッケージ 日本語フォーラム 日本語フォーラム 日本語化済みiso fossa64-simple-r1.iso
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

Gtk3プリのComboBoxの表示の簡略化

Gtk3アプリのComboBoxの表示の簡略化 ComboBoxの表示の書き方の課題 CellRendererTextやSetCellDataFuncを毎回書くのが面倒 拡張クラスの中で実行させ、書く行数を減らす using System; using System.Collections.Generic; using Gtk; using UI = Gtk.Builder.ObjectAttribute; namespace ComboBoxGtkApplication { class MainWindow : Window { [UI] private ComboBox _comboBox1 = null; List<Song> songs; public MainWindow() : this(new Builder("MainWindow.glade")) { } private MainWindow(Builder builder) : base(builder.GetRawOwnedObject("MainWindow")) { builder.Autoconnect(this); _mkComboBox(); } void _mkComboBox() { songs = new List<Song>(); songs.Add (new Song ("Dancing DJs vs. Roxette", "Fading Like a Flower")); songs.Add (new Song ("Xaiver", "Give me the night")); songs.Add (new Song ("Daft Punk", "Technologic")); _comboBox1._mkCellRendererText("Artist"); Gtk.ListStore musicListStore = new Gtk.ListStore (typeof (Song)); foreach (Song song in songs) { musicListStore.AppendValues (song); } _comboBox1._mkBinding(); _comboBox1.Model = musicListStore; } } public class Song { public Song (string artist, string title) { this.Artist = artist; this.Title = title; } //リフレクションを有効にするためgetとsetを書く public string Artist { get; set; } public string Title { get; set; } } } 解説 リフレクションを使うため、モデルにgeter seterを書く ComboBoxクラスを拡張クラスにする CellRendererTextExにCellRendererTextを親クラスにした派生クラス(継承)を作る CellRendererTextExの中にbindingPropertyNameにモデルのプロパティを指定する ComboBoxクラスを拡張クラス CellRendererTextを継承クラスにする using System; using System.Reflection; using Gdk; using Gtk; public static class objectExtensions { public static object _performSelector_Property(this object obj, string propertyName) { Type magicType = obj.GetType(); PropertyInfo pi = magicType.GetProperty(propertyName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly); MethodInfo getMethod = pi.GetGetMethod(); object result = getMethod.Invoke(obj, null); return result; } } namespace Gtk { public partial class CellRendererTextEx : Gtk.CellRendererText { public string BindingPropertyName = ""; } public static partial class ComboxExtensions { static public Gtk.CellRendererText _mkCellRendererText(this ComboBox Combox1 ,string baindingName) { Gtk.CellRendererTextEx CellRendererTextEx1 = new Gtk.CellRendererTextEx(); CellRendererTextEx1.BindingPropertyName = baindingName; Combox1.PackStart(CellRendererTextEx1, true); return CellRendererTextEx1; } static public void _mkBinding(this ComboBox Combox1) { if(Combox1.Cells.Length > 0) { Combox1.SetCellDataFunc(Combox1.Cells[0], new Gtk.CellLayoutDataFunc(_RenderComboDo)); } } static private void _RenderComboDo( Gtk.ICellLayout cell_layout, Gtk.CellRenderer cell, Gtk.ITreeModel model, Gtk.TreeIter iter) { if(!(cell is Gtk.CellRendererTextEx)) { return; } if((cell as Gtk.CellRendererTextEx).BindingPropertyName == "" || (cell as Gtk.CellRendererTextEx).BindingPropertyName == null) { Console.WriteLine("PropertyNameがない"); return; } object song = (object)model.GetValue(iter, 0); object value = song._performSelector_Property((cell as Gtk.CellRendererTextEx).BindingPropertyName); if(cell is Gtk.CellRendererText && (value is String)) { (cell as Gtk.CellRendererText).Text = value as String; } else if(cell is Gtk.CellRendererPixbuf && (value is String)) { (cell as Gtk.CellRendererPixbuf).Pixbuf = new Pixbuf((value as String)); } else if(cell is Gtk.CellRendererToggle && (value is String)) { (cell as Gtk.CellRendererToggle).Active = Convert.ToBoolean((value is String)); } else if(cell is Gtk.CellRendererProgress && (value is String)) { (cell as Gtk.CellRendererProgress).Value = Convert.ToInt32((value is String)); } else if(cell is Gtk.CellRendererPixbuf && (value is byte[])) { (cell as Gtk.CellRendererPixbuf).Pixbuf = new Pixbuf((byte[])value); } else if(cell is Gtk.CellRendererToggle && (value is Boolean)) { (cell as Gtk.CellRendererToggle).Active = (Boolean)value; } else if(cell is Gtk.CellRendererProgress && (value is int)) { (cell as Gtk.CellRendererProgress).Value = (int)value; } } } } 続く
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

Gtk3アプリComboBoxの表示の簡略化

Gtk3アプリのComboBoxの表示の簡略化 ComboBoxの表示の書き方の課題 CellRendererTextやSetCellDataFuncを毎回書くのが面倒 拡張クラスの中で実行させ、書く行数を減らす gladeファイルにCombBoxを配置します。 using System; using System.Collections.Generic; using Gtk; using UI = Gtk.Builder.ObjectAttribute; namespace ComboBoxGtkApplication { class MainWindow : Window { [UI] private ComboBox _comboBox1 = null; List<Song> songs; public MainWindow() : this(new Builder("MainWindow.glade")) { } private MainWindow(Builder builder) : base(builder.GetRawOwnedObject("MainWindow")) { builder.Autoconnect(this); _mkComboBox(); } void _mkComboBox() { songs = new List<Song>(); songs.Add (new Song ("Dancing DJs vs. Roxette", "Fading Like a Flower")); songs.Add (new Song ("Xaiver", "Give me the night")); songs.Add (new Song ("Daft Punk", "Technologic")); _comboBox1._mkCellRendererText("Artist"); Gtk.ListStore musicListStore = new Gtk.ListStore (typeof (Song)); foreach (Song song in songs) { musicListStore.AppendValues (song); } _comboBox1._mkBinding(); _comboBox1.Model = musicListStore; } } public class Song { public Song (string artist, string title) { this.Artist = artist; this.Title = title; } //リフレクションを有効にするためgetとsetを書く public string Artist { get; set; } public string Title { get; set; } } } 解説 リフレクションを使うため、モデルにgeter seterを書く ComboBoxクラスを拡張クラスにする CellRendererTextExにCellRendererTextを親クラスにした派生クラス(継承)を作る CellRendererTextExの中にbindingPropertyNameにモデルのプロパティを指定する ComboBoxクラスを拡張クラス CellRendererTextを継承クラスにする using System; using System.Reflection; using Gdk; using Gtk; public static class objectExtensions { public static object _performSelector_Property(this object obj, string propertyName) { Type magicType = obj.GetType(); PropertyInfo pi = magicType.GetProperty(propertyName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly); MethodInfo getMethod = pi.GetGetMethod(); object result = getMethod.Invoke(obj, null); return result; } } namespace Gtk { public partial class CellRendererTextEx : Gtk.CellRendererText { public string BindingPropertyName = ""; } public static partial class ComboxExtensions { static public Gtk.CellRendererText _mkCellRendererText(this ComboBox Combox1 ,string baindingName) { Gtk.CellRendererTextEx CellRendererTextEx1 = new Gtk.CellRendererTextEx(); CellRendererTextEx1.BindingPropertyName = baindingName; Combox1.PackStart(CellRendererTextEx1, true); return CellRendererTextEx1; } static public void _mkBinding(this ComboBox Combox1) { if(Combox1.Cells.Length > 0) { Combox1.SetCellDataFunc(Combox1.Cells[0], new Gtk.CellLayoutDataFunc(_RenderComboDo)); } } static private void _RenderComboDo( Gtk.ICellLayout cell_layout, Gtk.CellRenderer cell, Gtk.ITreeModel model, Gtk.TreeIter iter) { if(!(cell is Gtk.CellRendererTextEx)) { return; } if((cell as Gtk.CellRendererTextEx).BindingPropertyName == "" || (cell as Gtk.CellRendererTextEx).BindingPropertyName == null) { Console.WriteLine("PropertyNameがない"); return; } object song = (object)model.GetValue(iter, 0); object value = song._performSelector_Property((cell as Gtk.CellRendererTextEx).BindingPropertyName); if(cell is Gtk.CellRendererText && (value is String)) { (cell as Gtk.CellRendererText).Text = value as String; } else if(cell is Gtk.CellRendererPixbuf && (value is String)) { (cell as Gtk.CellRendererPixbuf).Pixbuf = new Pixbuf((value as String)); } else if(cell is Gtk.CellRendererToggle && (value is String)) { (cell as Gtk.CellRendererToggle).Active = Convert.ToBoolean((value is String)); } else if(cell is Gtk.CellRendererProgress && (value is String)) { (cell as Gtk.CellRendererProgress).Value = Convert.ToInt32((value is String)); } else if(cell is Gtk.CellRendererPixbuf && (value is byte[])) { (cell as Gtk.CellRendererPixbuf).Pixbuf = new Pixbuf((byte[])value); } else if(cell is Gtk.CellRendererToggle && (value is Boolean)) { (cell as Gtk.CellRendererToggle).Active = (Boolean)value; } else if(cell is Gtk.CellRendererProgress && (value is int)) { (cell as Gtk.CellRendererProgress).Value = (int)value; } } } } 続く
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む

Gtk3アプリのTreeViewの表示の簡略化

Gtk3 TreeViewの表示の簡略化 GtkSharpチュートリアルに書かれているサンプルを簡略化します treeViewの表示の書き方の課題 CellRendererTextやSetCellDataFuncを毎回書くのが面倒 拡張クラスの中で実行させ、書く行数を減らす using System; using System.Collections.Generic; using Gtk; using UI = Gtk.Builder.ObjectAttribute; namespace treeView3GtkApplication { class MainWindow : Window { [UI] private TreeView _treeView1 = null; List<Song> songs; public MainWindow() : this(new Builder("MainWindow.glade")) { } private MainWindow(Builder builder) : base(builder.GetRawOwnedObject("MainWindow")) { builder.Autoconnect(this); _mkTreeView(); } void _mkTreeView() { songs = new List<Song>(); songs.Add (new Song ("Dancing DJs vs. Roxette", "Fading Like a Flower")); songs.Add (new Song ("Xaiver", "Give me the night")); songs.Add (new Song ("Daft Punk", "Technologic")); Gtk.TreeViewColumnEx artistColumn = new Gtk.TreeViewColumnEx (); artistColumn.Title = "Artist"; //CellRenderの生成 artistColumn._mkCellRendererText(); //モデルのプロパティを指定する artistColumn.bindingPropertyName = "Artist"; Gtk.TreeViewColumnEx songColumn = new Gtk.TreeViewColumnEx (); songColumn.Title = "Song Title"; songColumn._mkCellRendererText(); songColumn.bindingPropertyName = "Title"; _treeView1.AppendColumn (artistColumn); _treeView1.AppendColumn (songColumn); Gtk.ListStore musicListStore = new Gtk.ListStore (typeof (Song)); foreach (Song song in songs) { musicListStore.AppendValues (song); } _treeView1._mkBinding(); _treeView1.Model = musicListStore; } } public class Song { public Song (string artist, string title) { this.Artist = artist; this.Title = title; } //リフレクションを有効にするためgetとsetを書く public string Artist { get; set; } public string Title { get; set; } } } 解説 リフレクションを使うため、モデルにgeter seterを書く treeViewを拡張クラスにする treeViewColumnにExを追加した派生クラス(継承)をにする bindingPropertyNameにモデルのプロパティを指定する TreeView拡張クラス using System; using System.Reflection; using Gtk; static class GtkExtensions { public static void _mkBinding(this TreeView treeView) { foreach (TreeViewColumnEx column in treeView.Columns){ if(!(column is TreeViewColumnEx)) { return; } TreeViewColumnEx columnt1 = (column as TreeViewColumnEx); columnt1._mkBinding(); } } } TreeViewColumnEx 派生クラス using System; using System.Reflection; using Gtk; using Gdk; public static class objectExtensions { public static object _performSelector_Property(this object obj, string propertyName) { Type magicType = obj.GetType(); PropertyInfo pi = magicType.GetProperty(propertyName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static | BindingFlags.DeclaredOnly); MethodInfo getMethod = pi.GetGetMethod(); object result = getMethod.Invoke(obj, null); return result; } } namespace Gtk { public class TreeViewColumnEx : TreeViewColumn { public String bindingPropertyName = ""; public CellRendererText _mkCellRendererText(string title = "",bool isPackStart = true) { if (title != "") { this.Title = title; } Gtk.CellRendererText CellRendererText1 = new Gtk.CellRendererText(); this.PackStart(CellRendererText1, isPackStart); return CellRendererText1; } public CellRendererPixbuf _mkCellRendererPixbuf(string title = "",bool isPackStart = true) { if (title != "") { this.Title = title; } Gtk.CellRendererPixbuf CellRendererPixbuf1 = new Gtk.CellRendererPixbuf(); this.PackStart(CellRendererPixbuf1, isPackStart); return CellRendererPixbuf1; } public CellRendererToggle _mkCellRendererToggle(string title = "",bool isPackStart = true) { if (title != "") { this.Title = title; } Gtk.CellRendererToggle CellRendererToggle1 = new Gtk.CellRendererToggle(); this.PackStart(CellRendererToggle1, isPackStart); return CellRendererToggle1; } public CellRendererProgress _mkCellRendererProgress(string title = "",bool isPackStart = true) { if (title != "") { this.Title = title; } Gtk.CellRendererProgress CellRendererProgress1 = new Gtk.CellRendererProgress(); this.PackStart(CellRendererProgress1, isPackStart); return CellRendererProgress1; } public void _mkBinding() { if(this.Cells.Length > 0) { this.SetCellDataFunc(this.Cells[0], new Gtk.TreeCellDataFunc(_RenderCellDo)); } } private void _RenderCellDo(Gtk.TreeViewColumn column, Gtk.CellRenderer cell, Gtk.ITreeModel model, Gtk.TreeIter iter) { if(!(column is TreeViewColumnEx)) { return; } TreeViewColumnEx columnt1 = (column as TreeViewColumnEx); if(columnt1.bindingPropertyName == "" || columnt1.bindingPropertyName == null) { Console.WriteLine("PropertyNameがない"); return; } object song = (object)model.GetValue(iter, 0); object value = song._performSelector_Property(columnt1.bindingPropertyName); if ( cell is Gtk.CellRendererText && (value is String)) { (cell as Gtk.CellRendererText).Text = value as String; } else if(cell is Gtk.CellRendererPixbuf && (value is String)) { (cell as Gtk.CellRendererPixbuf).Pixbuf = new Pixbuf(null, (value as String)); } else if(cell is Gtk.CellRendererToggle && (value is String)) { (cell as Gtk.CellRendererToggle).Active = Convert.ToBoolean((value is String)); } else if(cell is Gtk.CellRendererProgress && (value is String)) { (cell as Gtk.CellRendererProgress).Value = Convert.ToInt32((value is String)); } else if(cell is Gtk.CellRendererPixbuf && (value is byte[])) { (cell as Gtk.CellRendererPixbuf).Pixbuf = new Pixbuf((byte[])value); } else if(cell is Gtk.CellRendererToggle && (value is Boolean)) { (cell as Gtk.CellRendererToggle).Active = (Boolean)value; } else if(cell is Gtk.CellRendererProgress && (value is int)) { (cell as Gtk.CellRendererProgress).Value = (int)value; } } } } Gtk3アプリのComboBoxの表示の簡略化に続く
  • このエントリーをはてなブックマークに追加
  • Qiitaで続きを読む